Cannot connect to Compute Engine instance via SSH
A non-discussed answer is that you should have at least the standard memory on your VM instance (3.75GB) - do NOT use Micro VM instances.
I could only log in with SSH via browser console or gcloud command line, but not with Putty or Mac terminal SSH. I spent an hour on the phone with support and we found this to be the problem.
I have the same problem but found a workaround to connect via PuTTY manually.
In brief
- Generate SSH key for the machine instance
- Add SSH public key to the instance
- Prepare to log in - acquiring information for IP, login name, pass phrase, private SSH key
- Connect to the instance via SSH client, e.g. PuTTY in Windows
Detail steps
For me the gcloud quick start had already:
- launched my instance
- created my public and private RSA keys (in
C:\Users\USER_NAME\.ssh\
)
Public Key - C:\Users\USER_NAME\.ssh\google_compute_engine.pub
Private Key - C:\Users\USER_NAME\.ssh\google_compute_engine.ppk
- Go to the Google Developers Console in your browser
- Select your project and in the left hand nav bar click: Compute -> Compute Engine -> VM instances
- Your running instance(s) will be linked below the CPU usage chart
- Click the one you want and find the
Add SSH key
link and click it - Paste the entire contents of
google_compute_engine.pub
into the field that appears - Click Save and after a few seconds the key details will appear on the page (if you get an error you pasted from the wrong key file or didn't copy all the text)
- The first word in those details is your (case sensitive)
username
- Find the
External IP
above on the page Open PuTTY and paste the external IP into Host Name (port is the default of 22)
In the left hand nav expand: Connection -> SSH and then click Auth
- Next to "Private key file for authentication" click "Browse"
- Select "C:\Users\USER_NAME\.ssh\google_compute_engine.ppk" and click Open
- Scroll the left hand nav back up and click the top item "Session"
- Under "Saved Sessions" enter a name and click "Save"
- Accept the warning message and you should be prompted to login with the
username
from above step - Input your passphrase
- Done
Hope this helps. If someone has a solution for the gcloud issue I'd love to hear it too.