Add SSH Key Pair to Google Cloud

How to Add SSH Key Pair to Google Cloud in Windows

GCP or Google Cloud Console has gained a very decent ranking among the cloud fans because of its popularity, security and flexibility, moreover it is owned and operated by Google. Google Cloud Platform provides few methods to authenticate to a VM instance on its platform. One of them is by using SSH keys. GCP doesn’t have a way to generate SSH key pairs automatically. So users have to generate key pairs somewhere else. Windows users can create key pairs using a tool called Putty and Puttygen which helps to SSH into the website. You’ll learn how to generate and add SSH key pair to Google Cloud Compute Engine VM instance in this post.

Also read: Set Up Apache Virtual Hosts

Add SSH Key Pair to Google Cloud in Windows

SSH keys can be added to GCE per project basis and per VM instance basis. I’m looking into adding a project-wide SSH key pair in this post. Project-wide SSH key can be used for all VM instances in a project. Let’s get right into it. Learn How to Add SSH Key Pair to Google Cloud


  1. A working instance in Google Cloud Platform.
  2. Puttygen – putty-0.70.msiputty-64bit-0.70
  3. Putty

Step 1: Generate Key Pair

We can achieve generating a key pair in windows using a tool called Puttygen. Puttygen is a part of Putty utilities, we will come to them later. First, we need to install Puttygen and generate a key pair using it, download puttygen here.

puttygen screen

Make sure the Type of key to generate is set to RSA and click Generate. You’ll get a unique key pair within few seconds.

puttygen key pair

Next, you should provide a key comment under the Key comment label.  It’ll be RSA-key-followed by date by default. The key comment will be your username when you add this SSH key pair to VM instance. You probably need something easy to remember. I’ve changed it to techbiriyani in above example. You should change it too.

Next up is Key passphrase. It adds an extra layer of security to your private key and also helps in simplifying the login process. This is a password you set for your private key. The passphrase you set here will be asked during the authentication. Passphrase makes sure no one can log in to your VM even if they got hold of your private key file. Setting a passphrase is optional but recommended. Click Save private key and save it on a secure location, you may save it as a public key too by clicking Save public key button. Don’t lose these keys. You’ll be locked out of your VM if you lose this file. We’ll need the public key in the next step. But the private key is all you need after this setup is complete.

Keep the PuttyGen window open for now. Click on Load button

puttygen key pair loading

Select the Key Pair you saved in the previous step.

puttygen key pair load

Now enter the key passphrase given while generating the key pair

puttygen key pair load

Now select all keys generated under the label Key, copy it and we need to paste the same in your instance on Google Cloud Console.

puttygen key pair load

Trending posts:

Step 2: Add key pair to your Instance

Log in to your console and navigate to Compute Engine > Metadata. Switch to SSH keys tab. You’ll see an option to add your SSH key. Edit this field then copy and paste the public key from PuttyGen to the text field. Finally, save the public key.

That’s it. You can now use your private key to log in to any VM instance you create under this project. If at some point you wish to use a different SSH key pair for an individual VM instance, you can disable this project-wide key pair and add a new key pair from the VM instance settings. Hope you have successfully integrated your SSH key pair to Google Compute Engine.

If you’d like to encrypt your website contents, you can look at this article on How To Secure Apache with Lets Encrypt on Ubuntu 18.04.

Related threads:

Leave a Reply

Your email address will not be published. Required fields are marked *