SSH Into Google Compute Engine

October 29, 2020
Permission denied (publickey)

gcloud

gcloud compute ssh INSTANCE_NAME

If you have same INSTANCE_NAME across different zone, or multiple projects.

gcloud compute ssh --project=PROJECT_ID --zone=ZONE INSTANCE_NAME

If your local machine username differ from Compute VM Instance’s username, you will get Permission denied (publickey) (the username is usually extracted from your email/gmail account). Or you could create a local username which is same as the VM instance username.

NOTE: If you are unsure of the username of the VM instance

gcloud compute ssh USERNAME@INSTANCE_NAME

Browser

Goto https://console.cloud.google.com/compute/instances

Select your instance and click SSH.

NOTE: Use CTRL-SHIFT-C/V for copy and paste.

This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.