Let’s just say that Google Cloud’s SSH instructions aren’t the greatest. Here are the steps to SSH into your instance. It also assumes that you’ve installed the
gcloud program. These instructions are for MacOSX and Linux.
We start off by creating a new SSH key.
$ ssh-keygen -t rsa -f ~/.ssh/google_compute_engine -C email@example.com
ssh-keygen program will create a public and private key pair for you to use with Google Cloud.
Next, you’ll need the public key for your Google Cloud Console. Run:
$ cat ~/.ssh/google_compute_engine.pub
That will be output something like:
ssh-rsa AAAALOTSOFLETTERSAAAA firstname.lastname@example.org
Copy all of the output of the
cat command to your clipboard.
Go to the Metadata Page. Click on
Edit. Click on
Add new item. Paste the contents of your clipboard to the new key text box.
Go back to the terminal. Type in:
$ gcloud compute --project "your-project-name" ssh --zone "the-instances-zone" "instance-name"
And you’re SSH’d in to your instance.