How to ssh into GCP using Windows Terminal

Muhammad Saad
2 min readMay 11, 2022
Google Cloud Platform (GCP)

As we live in a world of automation, it does not seem right to do work specially in a tech space manually. We need automation to effectively work and progress. You can read the entire tutorial on my GitHub.

You can also view the tutorial on my YouTube channel. Video link is provided below:

There are three methods to access Google Cloud Platform project:

  • Access via Chrome
  • Access via Command Prompt
  • Access via a custom Windows Terminal tab (best!!)

Process for Chrome:

  1. Open Google Chrome
  2. Type “https://console.cloud.google.com/"
  3. And you can access it!!

Process for Installing Google Cloud SDK:

  1. Install Google Cloud SDK (https://cloud.google.com/sdk/docs/downloads-interactive)
  2. Click “Next”
  3. Click “I Agree”
  4. It’s installed!!

Process for Command Prompt (via PuTTy):

  1. Open Windows Terminal
  2. Then, open Command Prompt
  3. Type “gcloud cloud-shell ssh”
  4. And you can access it!!

Process for a custom Windows Terminal tab:

  1. Open Windows Terminal
  2. Go to Settings and click “Open JSON file”
  3. Then add the following:
{ 
"backgroundImage": "C:/Users/user/Downloads/Pictures/gcp.png",
"backgroundImageOpacity": 0.2,
"commandline": "wsl ~/ssh-gcloud-env.sh [email] [project_id]",
"hidden": false,
"icon": "C:/Users/user/Downloads/Pictures/gcp.png",
"name": "SSH into GCP"
},

4. Then, open your wsl2 Ubuntu VM, and in your /home/user/ directory make a file named “ssh-gcloud-env.sh”. And type in the following commands:

gcloud auth login $1
gcloud config set project $2
gcloud cloud-shell ssh

Link for the file:

5. Save the file and type the following:

chmod +x ssh-gcloud-env.sh

6. Finally, go to your Windows Terminal and open the custom tab.

Yay! We did it!!! 🎉🎉🎉

--

--

Muhammad Saad

I am a DevOps Engineer working on cloud technologies (AWS, GCP, Azure) at Xgrid.co