Kai Kiat Poh
Kai Kiat Poh

Reputation: 11

GCP compute scp error: You do not currently have an active account selected

I am trying to transfer a folder from my local machine to a VM in gcp

I am running

gcloud auth login
gcloud config set account 'my-gmail-account'
sudo gcloud compute scp path/to/folder $VM_ID:$REMOTE_DIR --project=$PROJECT_ID --recurse

It keeps giving me the error below even though I have logged in to the correct account. This problem has never happened when I am running on spare mac computer but it occurs on my ubuntu (I am not even sure if it is an os related issue).

ERROR: (gcloud.compute.scp) You do not currently have an active account selected.

Please run:

  $ gcloud auth login

to obtain new credentials.

If you have already logged in with a different account:

    $ gcloud config set account ACCOUNT

Upvotes: 1

Views: 7526

Answers (1)

guillaume blaquiere
guillaume blaquiere

Reputation: 76073

The config file are stored in a location related to your user (~/.config/gcloud/).

If you change the current user, you change the current user-config location. In your code you configure GCLOUD with your user account and you use it with the ROOT account. It fails, it's normal.

Perform all your command with sudo, or without. But not mix the two.

Upvotes: 3

Related Questions