Cesar V.
Cesar V.

Reputation: 21

Why is my VM instance stuck when I try to do SSH?

When I build a VM default settings with Ubuntu 16 and CentOS 7 (those are the ones I've tried) I keep getting stuck when I try to do SSH. The message is:

Establishing connection to SSH server...

And then it times out with:

You cannot connect to the VM instance because of an unexpected error.
Wait a few moments and then try again. (#79)

I enabled OS login hoping the behavior will change but it just stays stuck.

Everything is default except that I enabled "HTTP and HTTPS" access when creating the VM. (I tried building it without these options checked and I get to the same problem.

Upvotes: 2

Views: 6096

Answers (3)

Karthic Raghupathi
Karthic Raghupathi

Reputation: 2061

In case you are doing this from the GCP cloud console, you need to have a firewall rule that allows TCP ingress traffic from the IP range 35.235.240.0/20, port: 22.

Here are the steps:

  • Open the Firewall Rules page.
  • On the Firewall Rules page, click Create firewall rule.
  • Configure the following settings:
    • Name: allow-ingress-from-iap
    • Direction of traffic: Ingress
    • Target: All instances in the network
    • Source filter: IP ranges
    • Source IP ranges: 35.235.240.0/20
    • Protocols and ports: Select TCP and enter 22,3389 to allow both RDP and SSH.
  • Click Create.

Once this is complete, you can use SSH in the browser.

Upvotes: 0

Pradeep Bhadani
Pradeep Bhadani

Reputation: 4741

Can you make sure that you have port 22 allowed from your network to the VM? You can create a rule by going to VPC --> Firewall Rules --> Create New Rule.

This page has detailed steps.

Hope this helps.

Upvotes: 2

AdolfoOG
AdolfoOG

Reputation: 186

As manesioz commented, follow this guide to discard the common issues, as you said that this happens immediately after creation, most likely you're missing some firewall rules. Also consider to do a nmap scan to see if the port 22 is open in your instance. Do the next in cloud shell:

sudo apt-get install -y nmap

nmap -Pn YOUR_EXTERNAL_IP

Look for port 22 open

Upvotes: 1

Related Questions