Configuring gsutil for multiple buckets using different JSON files

HI All,
I have two bucket one in uk another one in us

The instance is in US now I want to access after instance login by default
when I do gsutil ls this should pull form the uk bucket

if my shell script execute with the specific json file that need to authenticated to the give json file and has to access the
bucket in Uk

First one I achieve by gsutil config -e and given the json file

How to do the second json file when I needed

Why do you need two keys? If the same VM needs to access both buckets can’t you simply grant the VMs service account permissions to both? Or perhaps I need a bit more understanding of your scenario.

Also I would suggest using gcloud storage rather than gsutil

Agree with this - I would give the same account permission to both buckets if at all possible

setting GOOGLE_APPLICATION_CREDENTIALS should also work, though, IIRC

assume the missing n on the filename is a typo (.jso vs .json)?

if you’re using keys you’re doing it wrong

Ok in details I want to securely access the Bucket one created in US with separate project and another one created in UK another project
now the instance I created in US with US project now how do I access the two different project bucket to be access

the compute is running with some associated SA. give it permissions to the bucket

u mean to say should I have to use this method

gcloud auth activate-service-account SERVICE_ACCOUNT@DOMAIN.COM --key-file=/path/key.json --project=PROJECT_ID

without key file is it possible

Where are you running the transfer from? a Google Cloud VM?

if it’s a gcp VM, you shouldn’t need to configure any service account; you should have implicit access with the identity of the service account attached to the machine itself (either the project default compute one, or a different one, if configured