How to access SSH keys for a Google Cloud Platform Compute Engine VM instance?

 Easiest way for creating and using one pair of ssh keys for multiple instances:

Step 1: Install putty and puttyGen from https://putty.org/

Step 2: Open a terminal in your local desktop / laptop (in Windows 10 and later you use Windows Linux Subsystem)

Type: ssh-keygen

Enter a name for the filename at the prompt: e.g. google_key

2 files will be created google_key and google_key.pub

Step 3: Copy the entire contents of the google_key.pub

Note there is no new line character. It should all be in one line.

Step 4: Before creating any VM instance, go to Compute Engine -> Metadata

Select "SSH keys" tab and click "Add SSH" keys

Paste the contents of the google_key.pub. If you pasted the contents properly, you sho
uld see the username appear on the left label. Then hit save.

Step 5: Now create your favorite VM instance under google compute.

Copy the External IP vm_instance_external_ip

Go back to your linux terminal and type

ssh -i google_key.pub username@vm_instance_external_ip

Type "yes"

And now you should be good to go.

If you need video instructions, see here

Next Post Previous Post
No Comment
Add Comment
comment url