Google Cloud Platform - SSH Connection Refused

You can check if the instance is open to connections on port 22 by running sudo nmap -Pn -p 22 <instance IP>.

If you have port 22 open in the instance you should check the serial console output for errors in sshd.

If there are no errors, try testing connectivity to the instance by using telnet IP 22. You should get the SSH prompt. When testing try the internal IP and the external one (if you have one). If there is no SSH prompt, this would indicate that the service is down in the other instances. You might also try connecting to other VMs using the browser or the serial console to verify the service status.


By enabling the serial port connection I was able solve the Connection refused issue. Please refer to this "Thinking in Software" blog where Nestor Urquiza infers that connecting to serial console restarts ssh. He says

Went ahead and activated the serial port access:

gcloud compute instances add-metadata myvm \
    --metadata=serial-port-enable=1