- To SSH into your Google Cloud instance, you need to create a new SSH key using the `ssh-keygen` program.
- The program will create a public and private key pair for you to use with Google Cloud.
- To get the public key for your Google Cloud Console, run `cat ~/.ssh/google_compute_engine.pub` and copy the output.
- Go to the Metadata Page in the Google Cloud Console, click on Edit, then Add new item, and paste the contents of your clipboard to the new key text box.
- Finally, go back to the terminal and type in `gcloud compute --project "your-project-name" ssh --zone "the-instances-zone" "instance-name"` to SSH into your instance.
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 yourgooglecloudemailaddress@example.com
The 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 yourgooglecloudemailaddress@example.com
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.