Automating gsutil commands

You should be able to do this without diving in too deep to the implementation of authentication for gsutil.

If you're using standalone gsutil (if you installed via this method), the instructions in the linked question are still valid (as Travis points out).

If you'd like to continue using the gsutil supplied via the Cloud SDK, you should use service accounts. Service accounts are the preferred method of authenticating on headless machines or in non-interactive contexts.

Your flow would look something like the following:

  1. Create a service account via the Google Cloud Developers Console.
  2. On the remote machine, install the Cloud SDK and gsutil. If you're not installing interactively, it's better to skip the curl ... | bash method. Instead, download this install archive, extract it, and run the install.sh script. This script has options (visible with --help); if you specify choices to all of these options, it won't prompt you.
  3. Copy the service account to the remote machine. Run gcloud auth activate-service-account --key-file=/path/to/service-account.json.
  4. Run gsutil. You should be appropriately authenticated.

You have to set defult project & user to gsuitl run the command on the command line on window/terminal on MAC

gcloud init

chose 1

it will show you diffrent user select the user & then select the project