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

This will prompt you a small dialog box with a command, something like below.

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.

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.”

Enter the port number and click “OPEN”

You will have your VM SSH session in the 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. Here’s how to how to find external IP of Google Cloud VM.

How to Connect Google Cloud VM on Custom Port  - 11How to Connect Google Cloud VM on Custom Port  - 12How to Connect Google Cloud VM on Custom Port  - 96How to Connect Google Cloud VM on Custom Port  - 83How to Connect Google Cloud VM on Custom Port  - 67How to Connect Google Cloud VM on Custom Port  - 65How to Connect Google Cloud VM on Custom Port  - 99How to Connect Google Cloud VM on Custom Port  - 70How to Connect Google Cloud VM on Custom Port  - 79How to Connect Google Cloud VM on Custom Port  - 24How to Connect Google Cloud VM on Custom Port  - 5How to Connect Google Cloud VM on Custom Port  - 22How to Connect Google Cloud VM on Custom Port  - 14How to Connect Google Cloud VM on Custom Port  - 91How to Connect Google Cloud VM on Custom Port  - 11How to Connect Google Cloud VM on Custom Port  - 23How to Connect Google Cloud VM on Custom Port  - 80How to Connect Google Cloud VM on Custom Port  - 23How to Connect Google Cloud VM on Custom Port  - 28How to Connect Google Cloud VM on Custom Port  - 50How to Connect Google Cloud VM on Custom Port  - 21How to Connect Google Cloud VM on Custom Port  - 51How to Connect Google Cloud VM on Custom Port  - 15How to Connect Google Cloud VM on Custom Port  - 85How to Connect Google Cloud VM on Custom Port  - 77How to Connect Google Cloud VM on Custom Port  - 80How to Connect Google Cloud VM on Custom Port  - 96