gcloud compute scp says you do not have an active account selected
You do not currently have an active account selectedShort 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.
Fix it fast
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 list2Match what you see, then jump to its fix
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 list2Fix
Log in. The account you log in with becomes the active one.
gcloud auth login3Verify
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
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 list2Fix
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 listConfirmed by docs.cloud.google.com
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 list2Fix
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-browser3Verify
gcloud auth list shows the account.
gcloud auth listConfirmed by docs.cloud.google.com
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
Security
gcloud init cannot finish the sign-in step
Enter authorization code
gcloud init signs in through a browser.
3 causes, each with a fixServers
Status code 460 on an AWS Application Load Balancer
elb_status_code 460 in ALB access logs
A 460 is generated by the load balancer, not by your app.
3 causes, each with a fixServers
Application Load Balancer returns 504 for requests to EC2 instances
HTTPCode_ELB_504_Count
A 504 from an Application Load Balancer means it could not get an answer from a target in time.
4 causes, each with a fixServers
apk cannot find py-pip in an Alpine Docker image
py-pip (no such package):
On current Alpine releases there is no package called py-pip.
2 causes, each with a fixServers
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 fixServers
ng serve runs in the container but localhost:4200 does not open
The browser cannot open localhost:4200 although ng serve is running in the container
ng serve listens on localhost by default, which inside a container is the container itself.
3 causes, each with a fix