0

I just restarted my google cloud compute engine instance and now I cannot SSH login to it. Before restarting, it worked fine. I tried fully stopping it and then starting again. There was a webserver on it and if I try to access any API method, I get timeout.

If I try to login from console website: enter image description here

If I try to login from terminal:

ssh: connect to host 104.197.20.65 port 22: Operation timed out
ERROR: (gcloud.compute.ssh) [/usr/bin/ssh] exited with return code [255]. See https://cloud.google.com/compute/docs/troubleshooting#ssherrors for troubleshooting hints.

What is wrong?

Gintas_
  • 4,940
  • 12
  • 44
  • 87
  • Stack Overflow is a site for programming and development questions. This question appears to be off-topic because it is not about programming or development. See [What topics can I ask about here](http://stackoverflow.com/help/on-topic) in the Help Center. Perhaps [Super User](http://superuser.com/) or [Unix & Linux Stack Exchange](http://unix.stackexchange.com/) would be a better place to ask. – jww Oct 30 '17 at 16:34
  • Possible duplicate of https://stackoverflow.com/questions/31293954/cannot-connect-to-google-compute-engine-instance-via-ssh-in-browser – Alvaro Rodriguez Scelza Jan 04 '20 at 18:12
  • Does this answer your question? [Cannot connect to Google Compute Engine instance via SSH in browser](https://stackoverflow.com/questions/31293954/cannot-connect-to-google-compute-engine-instance-via-ssh-in-browser) – Alvaro Rodriguez Scelza Jan 04 '20 at 18:13

2 Answers2

1

As the error message suggest the first thing to do is check the firewall rules. There must be a rule allowing connections from any ip (0.0.0.0/0) through the port 22. I assume that your instance's ssh was working before, so it can be two things.

  1. The rule is being applied to a certain network, and the network configuration of the VM was changed when it was shutted down.

  2. The rule is not being applied to the VM, maybe it is in a subnetwork, closing the communication.

To simplify the solution:

A- Add a network tag to your VM. (Ex. ssh-conn) https://cloud.google.com/compute/docs/vpc/add-remove-network-tags

B- Create a rule to allow connections from any ip and apply it to the network tag previously created. https://cloud.google.com/compute/docs/vpc/using-firewalls

Nilo_DS
  • 889
  • 7
  • 14
0

I had the same problem, and tried lots of way but none of them work.

But the way below is work for me:

  1. Connect to instance by serial console.
  2. vi /etc/ssh/sshd_config, delete the hash tag before Port 22, like this:
Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

Hope it work for you too.

Fanco
  • 54
  • 3