Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use gsutil with multiple accounts?

I frequently use Google Cloud Storage with at least two accounts: [email protected] and [email protected]. I used gsutil config to create .boto files for both accounts, which I've renamed to personal.boto and work.boto.

It is tiring to have to remember to type cp personal.boto ~/.boto whenever I need to switch between these accounts. Is there a better way?

like image 402
fejta Avatar asked Jan 18 '13 23:01

fejta


People also ask

How do I switch accounts on gcloud?

If you want to switch the account used by the gcloud CLI on a per-invocation basis, override the active account using the --account flag.

What is the difference between gsutil and gcloud?

"gcloud" can create and manage Google Cloud resources while "gsutil" cannot do so. "gsutil" can manipulate buckets, bucket's objects and bucket ACLs on GCS(Google Cloud Storage) while "gcloud" cannot do so.


3 Answers

The Google Cloud SDK now includes the gcloud tool, which allows you to login and easily switch between accounts.

$ gcloud auth list
Credentialed accounts:
 - [email protected] (active)
To set the active account, run
 $ gcloud config set account <account>

To login to another account, simply run $ gcloud auth login and use another Google account.

like image 135
Hanxue Avatar answered Nov 11 '22 16:11

Hanxue


Easiest way to do this is as follows:

$ BOTO_CONFIG=/path/to/personal.boto gsutil cp #...

For more detailed variations on this theme see this thread.

like image 22
fejta Avatar answered Nov 11 '22 15:11

fejta


For this, use following command to switch to the account you want.

gcloud auth login

This will take you to the Google account switch page which can be used to switch to the relevant user.

like image 31
udayanga Avatar answered Nov 11 '22 15:11

udayanga