SSH to 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
Step 1 – Install Putty
Go to the PuTTY website (https://www.chiark.greenend.org.uk/~sgtatham/putty/) and download the latest version of the installer.
Once the download is complete, double-click on the installer file to run it.
Follow the on-screen instructions to install PuTTY.
Step 2 – Create an SSH Key
Open the Putty Key Generator from the Putty folder on your start menu.
Click generate and follow the on-screen prompts to wiggle the 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.
Step 3 – Copy your SSH key to your Cloud Provider
In this example, I am using the Google Cloud Platform
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 your key value and username
Click save and make a note of the external IP of the server.
Step 4 – SSH to Instance
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 your GCP Instance. Log in with the credentials you provided earlier.