Cloud SDK command gsutil config -a

6/9/2017

I'm trying to include the credentials for my Google storage in my Dockerfile so that I don't have to do it every time I create a new Pod or another dies in Kubernetes. So is there a way to put this command like this

 gsutil config -a (Access Key) (Secret)

rather than running the command

 gsutil config -a

and then inserting the (Access Key) and (Secret) manually.

Thanks

-- montatich
docker
google-cloud-platform
google-cloud-sdk
google-cloud-storage
kubernetes

1 Answer

6/9/2017

You can pass the input using echo and pipe it to gsutil.

Do keep in mind why the gsutil command does not accept command line args - commands are stored in history files in your shell and can easily leak your secrets if they contained these secrets as command line arguments.

So the following command will get stored in shell history (unless you prevent it in some other way) and could contain your secret.

$ echo -e "$ACCESS_KEY_ID\n$ACCESS_KEY_SECRET\n" | gsutil config -a

This command will configure HMAC credentials, but gsutil will use
OAuth2 credentials from the Cloud SDK by default. To make sure the
HMAC credentials are used, run: "gcloud config set
pass_credentials_to_gsutil false".

This command will create a boto config file at /Users/tuxdude/.boto
containing your credentials, based on your responses to the following
questions.

Boto config file "/Users/tuxdude/.boto" created. If you need to use a
proxy to access the Internet please see the instructions in that file.
What is your google access key ID? What is your google secret access key?
-- Tuxdude
Source: StackOverflow