How can I use gsutil with multiple accounts?
Asked Answered
R

4

45

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?

Reginaldreginauld answered 18/1, 2013 at 23:49 Comment(0)
R
20

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.

Reginaldreginauld answered 18/1, 2013 at 23:49 Comment(0)
L
62

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.

Leucotomy answered 18/1, 2014 at 19:39 Comment(0)
R
20

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.

Reginaldreginauld answered 18/1, 2013 at 23:49 Comment(0)
S
11

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.

Sp answered 17/4, 2018 at 10:8 Comment(1)
That’s already in this existing answer written more than 4 years earlier.Ironmaster
C
-1

under windows OS: set BOTO_CONFIG=E:\.boto & e:\gsutil\gsutil.py ls s3://your_bucket/folder

The "E:" is hard driver id in Windows OS. If you have no "E:", just put the full path of your ".boto" file to try.

Commotion answered 29/6, 2015 at 6:0 Comment(1)
Looks like you probably want to add a little more explanation of what this does. Right now, if anyone runs this, 1. it wont work for them, since they dont have E:, 2. without any explanation, they don't know what E: should be.Semitrailer

© 2022 - 2024 — McMap. All rights reserved.