I am unable to SSH into my instance on the Google Cloud Services.

I am not very well versed in VM management and troubleshooting, but have tried everything I knew, and google could provide to me including:

  • Attempting to SSH from an external program
  • Copying and mounting the disks on a new instance
  • Connecting to both using the serial console
  • Try all of above in a different hosting location

No matter what I try, the only result is a loading symbol followed by this:

The key transfer to project metadata is taking an unusually long time. Transferring instead to instance metadata may be faster, but will transfer the keys only to this VM. If you wish to SSH into other VMs from this VM, you will need to transfer the keys accordingly.

I can't do this, as I don't have the private key that is used by GCloud to SSH into the instance, and using PuTTY simply is not working, as any Public Keys given to the server by me don't work at all.

  • What OS is the instance? What did you do before this happened? Dec 21, 2018 at 4:05

6 Answers 6


Google have developed a troubleshooting script for VM instances having problems with SSH connectivity. Here is the link: https://github.com/GoogleCloudPlatform/compute-ssh-diagnostic-sh

  • Also, FYI for others, it says on the page "The tool does not aim to fix any issues, just log information for analysis"
    – Anupam
    Mar 4, 2021 at 7:17

One of the reasons for receiving this error is that the firewall rules for the VPC are not configured to allow SSH ingress access to the instance. You can validate this configuration in the Google Cloud Console:

  1. Go to the project that your VM is active in
  2. Using the left side popout menu, select 'VPC network'
  3. Click on Firewall rules
  4. Check for a rule that allows SSH access via TCP on port 22 with a target that is inclusive of your instance or 'Applies to all'
  5. If the rule is missing, create the firewall rule, for the 'Source IP Ranges', enter the public IP address of your Internet connection or enter to allow connections from anywhere on the Internet
  • 3
    The firewall rules for port 22 have already been set to all. I had access to this VM until the other day. no idea why it's doing htis to me. Dec 23, 2018 at 20:31

This can also occur if the boot disk is full on the instance. Google Cloud troublshoot connection errors


Stopping and starting the VM instance solved it for me. You can do that via console...

enter image description here

...or via command line:

gcloud compute instances stop <vm-instance-name>
gcloud compute instances start <vm-instance-name>

I have no evidence to support this, but I think what's causing the problem for me is trying to use Remote-SSH in VSCode—I think it may be spawning processes on the server that don't behave well after disconnections (and connection retries).


Public keys need to be enabled before they can be used by third party tools to access VM instances, was this done for the VM you are trying to connect through?

SSH access issues can be debugged through the /var/log/auth.log (Path is OS dependent so look for the correct path for your version of OS) or you can review the serial console output to view some additional details to help you troubleshoot the problem.

If you identify the possible root cause of the issue, you can enable interactive access to the serial console to fix it.

If you don’t have the root password, you can:

1. Go to the VM instances page in Google Cloud Platform console. 
2. Click on the instance for which you want to add a startup script. 
3. Click the Edit button at the top of the page.
4. Click on ‘Enable connecting to serial ports’
5. Under Custom metadata, click Add item. 
6. Set 'Key' to 'startup-script' and set 'Value' to this script: 
#! /bin/bash 
useradd -G sudo USERNAME 
echo 'USERNAME:PASSWORD' | chpasswd 
7. Click Save and then click RESET on the top of the page. You might need to wait for some time for the instance to reboot. 
8. Click on 'Connect to serial port' in the page. 
9.  In the new window, you might need to wait a bit and press on Enter of your keyboard once; then, you should see the login prompt. 
10.. Login using the USERNAME and PASSWORD you provided.

Serial console access is not secure so it is recommended that you disable it once you complete your work.

You can also debug this by running SSH Diagnosis scripts from a Linux Guest environment which are included with Linux instances created using Google-provided public images.

  • I've tried this. No luck. Jan 3, 2019 at 3:35

I have had this problem every once in a while. I can access the VM via browser ssh but not my own ssh client, whilst all http services are down. This is on an f1-micro instance (the always-free tier). Some linear combination of these steps seems to always work:

  1. Reset the instance
  2. Wait for a couple of minutes
  3. VM Instances > [my machine] > Edit. Set machine type to the same as you have right now, forcing a clone and internal migration on Google's end.
  4. Disable anything that could potentially take up 100% CPU, Google seems to cut your machine off if that ever happens.
  5. Upgrade to g1-small. It costs about 3x more (for me at least) but it has a lot less of these mysterious problems.

This particular time (2020-01-03), 3 and 2 solved my problem.

  • hmm, tried all 5 but didn't work. The machine and ssh was working fine until I decided to turn off the machine when I was done for the day (to save costs) but could never ssh back in when it was restarted.
    – Anupam
    Mar 4, 2021 at 7:19
  • @Anupam did you resolve the issue. Any of those solutions works for me as well.
    – xzegga
    Sep 17, 2021 at 3:20
  • 1
    @xzegga the easiest solution is to ditch GCloud and just buy a raspberry pi and plug it in at home into your router. Total estimated costs for electricity is very low, and ssh has never failed me when self hosting. All these mysterious things go away and I can finally sleep good again Sep 18, 2021 at 6:01
  • @xzegga No, I had to start up another instance
    – Anupam
    Sep 19, 2021 at 15:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .