GCP Error: "Unable to connect on port 22"

0 votes

While trying to connect to an Linux VM instance that I have configured on google cloud, I choose the method "SSH  in browser" but I can't connect to it. it shows this error:

Unable to connect on port 22

How should i troubleshoot this issue?

Sep 24 in GCP by anonymous
• 3,950 points
69 views

1 answer to this question.

0 votes

You may see this error under the following conditions:

  • The instance is booting up and sshd is not yet running. Verify that the instance has finished booting up before trying again.

  • The instance is not running sshd. sshd runs by default on instances created from standard Compute Engine images. If you have manually disabled sshd or you have configured a custom image that is not running this service, SSH from the Browser will not work.

  • sshd is listening on a port other than the one you are connecting to. By default, SSH from the Browser connects to the instance on port 22. If you are running sshd on a custom port, you can connect to that port using "Open in browser window on custom port" item in the SSH button drop-down menu.

  • There is no firewall rule allowing SSH access on the port. SSH access on port 22 is enabled on all Compute Engine instances by default. If you have disabled access, SSH from the Browser will not work. If you run sshd on a port other than 22, you need to enable the access to that port with a custom firewall rule.

  • The firewall rule allowing SSH access is enabled but is not configured to allow connections from GCP Console services. Source IP addresses for browser-based SSH sessions are dynamically allocated by GCP Console and can vary from session to session. For the feature to work, you must allow connections either from any IP address or from Google's IP address range which you can retrieve using public SPF records.

  • The instance is shut down. Verify that the instance is up and running. 

Hope this helps!

answered Sep 24 by Sirajul
• 31,540 points

Related Questions In GCP

+1 vote
2 answers

How to open a port on google compute engine

You need to set the firewall rule ...READ MORE

answered Jul 9 in GCP by K sagar
125 views
0 votes
1 answer

Creating a SQL Server instance using Google Compute engine.

Google Compute Engine provides public images preconfigured with ...READ MORE

answered Sep 23 in GCP by Sirajul
• 31,540 points
26 views
0 votes
1 answer

How do i install gcloud compute?

The gcloud compute command-line tool enables you to easily ...READ MORE

answered Sep 23 in GCP by Sirajul
• 31,540 points
26 views
0 votes
1 answer

How to allow outbound traffic on a custom port in gcp?

To allow outbound traffic through a custom ...READ MORE

answered Sep 26 in GCP by Sirajul
• 31,540 points
23 views
0 votes
1 answer

Cannot connect to my VM instance on GCP via SSH.

This might be because UFW is installed. ...READ MORE

answered Sep 27 in GCP by Sirajul
• 31,540 points
30 views