Share on facebook
Share on twitter

SSH into Google Cloud: The Definitive Guide [2019]

In this post you will learn about how to SSH into Google Cloud Platform Vm instances.

After this tutorial you can connect via SSH into Google cloud by using Windows or Mac Os or Linux Operating system.

Basic FAQs:

What is SSH ?

Secure Shell (SSH) is a cryptographic network protocol for operating network services securely over an unsecured network. Typical applications include remote command-line, login, and remote command execution, but any network service can be secured with SSH. by Wikipedia.

So, Simpally, SSH help you to Connect and Control you remote server , Operating system over an secure network. An SSH server, by default, listens on the standard Transmission Control Protocol (TCP) port 22

What is Private and Public key ?

If you want to connect via ssh into Google Cloud ,Then you have to generate Private and Public keys.

Public key: You will transfer this key to a server, which you want to connect via SSH. Eg Google Cloud Vm Instances.

Private key: Private keys which are known only to the owner. You should not share this key to anyone. Eg. You local Computer.

Join Us




Want Exclusive Tutorials?

SSH into Google Cloud using Web Console SSH.

If you want to execute some code you don’t need any fancy SSH client setup. Google Cloud Platform has built in SSH, Which you can access through your web browser.

How to access Google cloud console SSH ?

Login to Your Google cloud platform account. Then go to Console. On the right hand corner click the hamburger button. 

Now hover on Compute Engine and Click on VM Instances.

Then Click on the SSH button to SSH into your google cloud server.

Here on my VM Instances I already set up a Google Click to deploy WordPress. By clicking on SSH I can execute Command on that particular server.

For Windows

SSH into Google Cloud using PuTTy.

PuTTY  is a free and open-source terminal emulator , serial console and network file transfer application. Simply if you want to connect and execute commands on a remote Linux/Unix server, You will have to use PuTTY software. It supports several network protocols, including SCP, SSH, Telnet, rlogin, and raw socket connection. It can also connect to a serial port.


  1. Download Putty.
  2. Install Putty on Your PC.
  3. Generate Public and Private Keys using Puttygen.
  4. Configure Google Cloud.
  5. Configure Putty.
  6. Connect via SSH into Google Cloud.

Let’s get started.

1#. Download PuTTy.

First thing you need to do is to download Putty. HERE is the link to Download putty.

2#. Install Putty on Your PC.

Next Step is to install putty on your computer.

3#. Generate Public and Private Keys using Puttygen.

Now click on your window button. Then search and open PuTTYgen to generate Public and Private keys.

Click on “generate” and move your mouse to create public and private keys.

I recommended you  to change the key comment field to something recognizable and easy to type, as this will become a user name later!

Save the private key. Later, This private key will be needed to configure putty.

Copy the Public key

I recommended you to also save the public key by clicking on ” Save public key” button. 

4#. Configure Google Cloud.

To configure Google Cloud  SSH, goto your Compute engine >> VM instances.

Open the setting section by clicking over the name of your VM instance.

Here I am running a debian 9.9 WordPress server. It does not matter what you are running.

Click on the edit Button.

After that scroll down and click on the “Show and edit” Button.

You need to paste the Public key which you copied.

After that Click on SAVE.

5#. Configure Putty.

Follow the steps below to setup your putty.

First thing you need to do is copy your VM Instance IP address.

Open Putty on your Computer. Then goto “Session” and paste the VM Instance IP address on the “HostName” section.

After that goto Connection>>Data. On the “Auto-login username” section type your “key comment“.

Now goto Connection >> SSH >> Auth. Browse and select the private key file which you already generated from puttygen. 

I recommended you to save the configuration or  you have to setup putty every time you wanna open SSH.

Click On OPEN.

6#. Connect via SSH into Google Cloud.

Just click on YES to SSH into Google Cloud.

As you can see I am connected to Google Cloud Vm Instances via SSH.

SSH into Google Cloud using Google Cloud SDK Tool.

Google develop a set of tools for Cloud Platform. It contains gcloud, gsutil, and bq command-line tools, which you can use to access Google Compute Engine, Google Cloud Storage, Google BigQuery, and other products and services from the command-line.

You can use google cloud sdk to ssh into your VM Instances.

You don’t need to generate keys or configure your instances settings.

All those things are automated in Google Cloud SDK.

Let’s get started.

Download the Google Cloud SDK . Here the link

Install Google Cloud SDK on you windows Pc.

After installing Google Cloud SDK, the google init terminal will open, and you will be asked to log in. Type “y” and press “enter”. Your browser will open up your Google accounts page, asking you to grant permissions for Google Cloud SDK.

When Cloud SDK ask  “do you want to configure Google Compute engine”. Type “y” and press “enter” to continue.

Next you will be prompted to select a zone. You can choose the zone that you selected when setting up your instance, But I recommended to choose “21” to not set a default zone.

After you configure your cloud sdk, go to you Google Cloud Platform dashboard. Goto Compute engine > VM Instances > SSH. Click on the “View gcloug command”

Select and copy your gcloud command.

Go back to your Google Cloud SDK terminal and paste the gcloud command. If you does not have ssh keys then the command will automatically generate public and private keys and also update you project metadata. 

The ssh keys will be stored in C:\Users\your-pc-name\.ssh directory.

After you paste your gcloud command into the SDK terminal,a another terminal will lunch.

As you can see you already connected via ssh in that terminal.

For Mac Os

SSH into Google Cloud using default mac terminal.

If you are using Mac Os then you don’t have to download any things, Because mac support SSH connection natively. 

You just need to generate two SSH keys  (public key and private key) to connect securely to your VM instances.


  1. Generate Public and Private keys using default mac terminal.
  2. Configure Your Google Cloud VM.
  3. Connect via SSH on mac.

1#. Generate Public and Private keys using default mac terminal.

Click on Utilities and after that open mac terminal.

Now execute the command below to generate public and private keys.
ssh-keygen -t rsa -C give-a-username

Leave the “Enter file in which to save the key” Blank to save those key in ~/.ssh folder.

Leave the passphrase empty.

You can check those keys by executing this command.

ls ~/.ssh

You have to copy that public key ( ) and place it to google cloud metadata. 

To copy your public key execute this command:

pbcopy < ~/.ssh/

2#. Configure Your Google Cloud VM.

After the previous step login to your Google Cloud Console and go VM Instances. Click on the name of your VM instances which you want to setup ssh.

Click on edit.

After that scroll down and click on “Show and edit .

Paste your public key.

Then click on save.

3#. Connect via SSH using Mac Os.

Now open your mac terminal again and execute the command below.

ssh your-user-name@your -instances-ip

Here what looks like when you successfully connected through ssh into google cloud via mac terminal.

Did it work ?

If you need help please drop a comment.

If you benefited from this tutorial, and would like to support my work, please like my Facebook page.


If you like our content, please consider buying us a coffee. Thank you for your support!

Leave a Comment

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