English English French French Spanish Spanish German German
Geekflare is supported by our audience. We may earn affiliate commissions from buying links on this site.
Share on:

How to Connect Google Cloud VM on Custom Port?

unix login prompt
Invicti Web Application Security Scanner – the only solution that delivers automatic verification of vulnerabilities with Proof-Based Scanning™.

One of the frequently asked questions I receive is how to login to Google Cloud Linux VM on a custom port using gcloud.

Google Cloud Platform (GCP) has multiple options to connect to the VM.

If you’ve changed default SSH port from 22 to something else and trying to connect using thengcloud you got to use --ssh-flag parameter.

Let’s see the command syntax.

Login to VM with Custom SSH Port Using gcloud

  • Log in to Google Cloud Platform and go to VM instances under Computer Engine
  • Click on the drop-down next to SSH >> view gcloud command

gcloud-command

  • This will prompt you a small dialog box with a command, something like below.
gcloud compute --project "PROJECT_NAME" ssh --zone "us-central1-b" "instance-1"
  • If you notice, custom SSH port is not defined in the command, and you have to add it manually.
  • Let’s assume SSH port is 2222 so gcloud command would be like below.
gcloud compute --project "PROJECT_NAME" ssh --zone "us-central1-b" "instance-1" --ssh-flag="-p 2222"

By adding --ssh-flag you instruct gcloud to connect the VM instance on a given port number instead of default one.

Login to VM with Custom SSH Port through Browser

Not using gcloud or SSH client? don’t worry.

GCP lets you access your VM directly through the browser. Go to VM instances and under SSH drop-down, select “Open in a browser window on a custom port.”

gcp-custom-port

  • Enter the port number and click “OPEN”

gcloud-enter-custom-port

  • You will have your VM SSH session in the browser

gcp-custom-port-browser

I hope this quick guide helps you. If you are looking to learn more about Google Cloud Platform, then I would recommend this online course by Dhanaji Musale.

Related:

Here’s how to how to find external IP of Google Cloud VM.

Thanks to our Sponsors
More great readings on Cloud Computing
Power Your Business
Some of the tools and services to help your business grow.
  • Invicti uses the Proof-Based Scanning™ to automatically verify the identified vulnerabilities and generate actionable results within just hours.
    Try Invicti
  • Web scraping, residential proxy, proxy manager, web unlocker, search engine crawler, and all you need to collect web data.
    Try Brightdata
  • Semrush is an all-in-one digital marketing solution with more than 50 tools in SEO, social media, and content marketing.
    Try Semrush
  • Intruder is an online vulnerability scanner that finds cyber security weaknesses in your infrastructure, to avoid costly data breaches.
    Try Intruder