Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Servers, nginx and Docker

gcloud compute scp says you do not have an active account selected

ErrorYou do not currently have an active account selected

Short answer

gcloud has no active account in the current configuration. Run gcloud auth list to see stored accounts. Log in with gcloud auth login if none exist, switch with gcloud config set account if one is stored but inactive, or use a credential file on servers without a browser.

  • Applies to Google Cloud CLI
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    List the accounts gcloud knows about. The result tells you whether to log in or only to switch.

    gcloud auth list
  2. 2Match what you see, then jump to its fix

    1. 1gcloud auth list shows no credentialed accountsNo account has ever logged in on this machineFix
    2. 2gcloud auth list shows accounts, but none is marked activeAn account is stored but none is activeFix
    3. 3The command runs on a remote machine or in a pipelineA server or CI job with no browser to log inFix

What does the error look like?

  • You do not currently have an active account selected

Cause 1 of 3

No account has ever logged in on this machine

1Check

An empty list means there is nothing to activate.

gcloud auth list

2Fix

Log in. The account you log in with becomes the active one.

gcloud auth login

3Verify

The account is listed and scp can reach the VM.

gcloud auth list
gcloud compute scp --zone=ZONE ./file.txt VM_NAME:~/

Confirmed by docs.cloud.google.com

Did this fix it?

Cause 2 of 3

An account is stored but none is active

1Check

Credentials are stored, so no login is needed, only a switch.

gcloud auth list

2Fix

Activate the account by its full identifier as listed, or use --account for one command only.

gcloud config set account PRINCIPAL_IDENTIFIER
gcloud compute scp --account=PRINCIPAL_IDENTIFIER --zone=ZONE ./file.txt VM_NAME:~/

3Verify

gcloud auth list marks the account as active.

gcloud auth list

Confirmed by docs.cloud.google.com

Did this fix it?

Cause 3 of 3

A server or CI job with no browser to log in

1Check

gcloud auth login needs a browser, and credentials it stores should not be used for automated workloads on persistent remote systems.

gcloud auth list

2Fix

Authorize with a credential file, or use the no-browser flow on a remote machine you control.

gcloud auth login --cred-file=KEY_PATH
gcloud auth login --no-browser

3Verify

gcloud auth list shows the account.

gcloud auth list

Confirmed by docs.cloud.google.com

Did this fix it?

How do I stop it coming back?

  • Run gcloud auth list at the start of a script so a missing login fails early.
  • Pass --account in scripts when more than one account is stored.
  • Use credential files or federation for automation, not a personal login.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Related fixes

Servers

dnf cannot install MySQL on Amazon Linux 2023

dnf cannot find a mysql-server package on Amazon Linux 2023

Amazon Linux 2023 documents MariaDB, not MySQL, as its database server, with packages named mariadb105 and mariadb105-server.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.