How to SSH directly to Google Cloud Platform (GCP) Linux instance?
The GCP console interface is very useful, but sometimes you may need to directly SSH from your on-premise infrastructure.
This is particularly common after you migrate a Linux server from your own premises to GCP as the Google Daemon which provides Google Cloud console access typically will not be installed.
If you are interested in the Google Daemon you can check here.
Windows Method using Putty
Open the Putty Key Generator from the putty folder on your start menu.
Click generate and follow on screen prompt to wiggle mouse to create randomness
Keep wiggling the mouse to generate the key
Enter the Username and password you want to use in the Key Comment and Key Passphrase sections. In this example I am using root, but you can use anything providing there is an associated account on the server.
Next copy the entire key box and click Save private key
Next Log into GCP and navigate to Compute Engine. Find the VM you want external SSH access to and click on it to see details.
In the details page click edit
Scroll down to the SSH Keys section, Click Add item and paste you key value and user name
Click save and make a note of the external IP of the server.
Go back to Putty.
Type the External IP of your server into the client
On the left pane, scroll down to expand connection > SSH > Auth
Click the browse button and locate the key file you saved earlier
Next click Open to SSH to you GCP Instance. Log in with the credentials you provided earlier.