habibzain Just husband, father and enthusiastic men about System Administration. Love to write short article about it. Perhaps can help and be useful for others.

How to Remote SSH to Google Cloud VM Instance

2 min read

SSH allows you to securely connect to a remote server and execute commands on it. In this blog post, I will show you how to use the Google Cloud Console and the gcloud command-line tool to remote SSH to your Google Cloud VM instance. In this tutorial, I will describe simple way through how to create a virtual machine in Google Cloud. We can connect to it with SSH Native and Putty from our computer.

Note: I assume that the Google Cloud Console has a properly deployed VM and has public IP access and SSH Default Port 22 open and allow.

Connect SSH VM Instance wih Putty

For windows user, I am very recommended PuTTY. Putty is open-source and easy to use SSH client.

Here is step by step remote VM GCP using putty.

  1. Download PuTTY and install from here.
  2. Open PuTTY Key Generator and click Generate.
    It will generate a random key. PLEASE MOVE our cursor over the blank area.
Remote SSH GCP VM Instance

After it is done, you will get something like this.

Remote SSH GCP VM Instance
Remote SSH GCP VM Instance
  1. Change “key moment” field to something easy to type.This will become a user name later.
  2. Click “Save private key” in safe place folder. We need import or load this private key when connect with putty.
  3. Paste the Public Key to Instance VM GCP. Edit VM and jumpt to SSH Section. Add Item.
Public key paste to VM GCP

Dont forget to Save. We can see the result like this.

Remote SSH GCP VM Instance
  1. Test login with putty. In the meantime go to SSH ->Auth and browse for the private key file that you saved.
See also  Upgrade Downgrade Unifi via CLI
Remote SSH GCP VM Instance
  1. Type Public IP and “Open”. Or we can click “Save” for next login.

Connect VM Instance GCP Via SSH Linux/Mac

Mac and Linux host came with SSH connection natively. We just need to generate an SSH key pair (public key/private key) to connect securely to the virtual machine.

The private key is equivalent to a password. In our host linux or mac, generate ssh-keygen. Next, choose a password for your login to the virtual machine or hit ENTER if you wish not to use a password. The private key (i.e. identification) and the public key will be generated as shown below.

habibza@LNV-MHZ:~$ ssh-keygen -t rsa

Generating public/private rsa key pair.
Enter file in which to save the key (/home/habibza/.ssh/id_rsa):
Created directory '/home/habibza/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/habibza/.ssh/id_rsa
Your public key has been saved in /home/habibza/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:f8zj9U7exPdql3E3sUiiF/LoaleqseHTqVCqh91trww habibza@LNV-MHZ
The key's randomart image is:
+---[RSA 3072]----+
|                 |
|                 |
|                 |
|         . o . . |
|       .S = + . o|
|      o  + * . =o|
|    oo.E+ * = . @|
|   ..oo+*O o o.*=|
|   .. .*Boo....+*|

Next, view the key and paste the keygen to Instance VM.

habibza@LNV-MHZ:~$ cat .ssh/id_rsa.pub

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDMfOtNavDuHB2uGmR1PcOpB3Yab0iCw2r8jELxdWU7/JmRPksq++UypJJUYj1bLNv++kWmCt+a2SyZ5/TNDllRGw9criisqGts3+1XeZszjEXnsfrv/c60Rmp0xNnJIp8oldQ2Y2ythO7BLdJpZaIj5yAJkvvsTkp6z/BOoomAzB+XdlVh9giEVGDZvpFHT1Lng4Rf12dQ+VRIYWo8289i6ruOu4rLD3gqYjE+MWhK3YHsImS7H3eXDkLy/xfjtS3dtK5HThEP4YGjCAmsbyAQrk+g36ofoAeilS+tUcN/IIZP2BuFyEHg1ReYES4r/xaW4W4OiZkWaZFpZTTSSIZr8InNblE3ytaku6daNqQ3uQK2yAvkYBQwu/hydS9UqqTCFjxPNpthpGcGxhJoi8nGGfaDYPU40LIktD/fC308+/qE6g7Q5D3olzGCGj3PfSWJbM2ldrvxG04092Zo3aHod5+PKAqw06MnKfRbYSCY17Jhi2YtO2z0d3LoazlNE= habibza@LNV-MHZ

Paste to Instance VM.

The last, test connect remote to Public IP VM instance via ssh in terminal.

habibza@LNV-MHZ:~$ ssh [email protected]

Until this step we can login to our vm.


  • Save the private and public key in safe place.
  • This method is just want remote SSH to instance VM. Not the GCP Environtment (project).
  • For security reason, set firewall in VM Network just allow from your IP Public PC can access your VM.
See also  Remove Private Key Passphrase with openSSL

Maybe usefull. Please feel free to comment.

habibzain Just husband, father and enthusiastic men about System Administration. Love to write short article about it. Perhaps can help and be useful for others.

Easy Create Laravel Project with Composer

Requirement Laravel, a popular PHP framework, is renowned for its elegant syntax and robust features, making it a top choice for web developers. One...
1 min read

Virtualbox Change Storage Size

Changing the storage size of a virtual machine in VirtualBox involves a few steps. Here’s a general guide. Backup your Virtual Machine (VM) Before...
35 sec read

Easy Setup Logrotate Nginx Ubuntu

Log rotation is an important aspect of managing log files on a Linux system, including those generated by Nginx. Logrotate is a utility that...
1 min read

Leave a Reply

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

Never miss good article from us, get weekly updates in your inbox