I am attempting to connect (via SSH) one GCE VM instance to another GCE VM instance (which will be referred to as Machine 1 and Machine 2 from now one).
So far I have generated (via ssh-keygen -t rsa -f ~/.ssh/ssh_key
) a public and private key on Machine 1, and have added the contents of ssh_key.pub
to the ~/.ssh/authorized_keys
file on Machine 2.
However, whenever I try to connect them via ssh using the following command: gcloud compute ssh --project [PROJECT_ID] --zone [ZONE] [Machine_2_Name]
it simply times out (Connection timed out. ERROR: (gcloud.compute.ssh) [/usr/bin/ssh] exited with return code [255].)
I have doubled checked that each VM instance has plenty of disk space, and their firewall settings are permissive, and OS Login is not enabled. I have read through the answer here but nothing is working.
What am I doing wrong? How do I properly SSH from one GCE VM instance to another?
--tunnel-through-iap
to bypass networking issues. Your changes to authorized_keys might have broken ssh. – John Hanleynetstat -lntu
i see that "tcp6 - 0 - 0 :::22 :::* LISTEN" , so seems like port 22 is listening. After adding--tunnel-through-iap
I get the error " Error while connecting [4033: u'not authorized']" – manesioz