Connect Gcp Instance Through Putty!

There are multiple ways of connecting to the terminal of an instance running in the cloud as in AWS it provides the .pem file which is used to authenticate with the running instance through putty or CMD/POWERSHELL. But in the case of GCP it doesn't provide the .pem file for authentication it connects you to the terminal via opening ssh through the browser in a new window. So here's a quick guide for users who want to use putty and other third-party tools.

As I mentioned it doesn't provide you with the .pem file you have to generate your own public and private key which can be generated via Puttygen. I assume you have downloaded putty and puttygen so lets start.

After downloading Putty and Puttygen open puttygen and click on Generate option for public and private keypair hover the mouse randomly on the blank area the key will be generated add the key comment. Here I have typed the example as my key comment remember this name it will be used for authentication. Now click on save public key and private key the private key will be saved as .ppk extension.

Now copy the public key generated and open the gcp compute engine console here i have a running instance of name example-1 click on the box of that instance select edit scroll down and you will find SSH Keys option it is below the Security and Acess click on "ADD SSH KEY " paste the public key here that you copied and click on Save.

Now Google add this key under the .ssh folder once you are logged in you can find that. Now to access this instance through putty open putty on the left panel you can see SSH option below click on that then click on AUTH browse the directory where your .ppk file is stored Now click on the session above and paste the public IP address of your instance then click on open it will ask for login username the username will be that one which we have provided in key comment after entering username you are logged in !! :)You can also add the public key under the Metadata option under that it has SSH keys tab open that and add your ssh key now this key will be global use for all the instances under your project so you will not need to add every time you launch the instances.

Did you find this article valuable?

Support MUSAIB SHAIKH'S BLOG by becoming a sponsor. Any amount is appreciated!