Ssh – Connecting to another subnet’s machine via ssh

local-area-networkssh

I want to connect to my VPS via ssh. The output of ssh is the following:

"No route to host"

It seems, that it's because I'm located at a LAN and have no public IP. So, my question is, how can I "tell" the ssh that route? I have no access to other devices of my LAN, because it's not mine. Also, I have no access to VPS, because it's in another country.

UPDATE: also, the ping command to my VPS works perfect and gives a result of about 300ms.

Best Answer

Ping working seems to indicate you have a route to internet. If you are using the ping to your VPS using its IP and ssh with the hostname is not working, try using ssh with the IP too because it may be a DNS issue.

If ping is working with the public hostname of your VPS, ssh should work the same unless there is something (firewall or proxy) blocking outgoing connections on port 22 or there is a proxy in the LAN not configured to proxy port 22 transparently (only 80 probably). If this is the case, you may be able to use ssh defining the proxy settings for the ssh connection (if the server allows it) but without knowing more it is not easy to indicate a real solution if any.

EDIT after comments:

Seeing telnet on port 80 works and not on port 22, outgoing is probably blocked on port 22 (assuming your VPS ssh server is working and listening!). I think you have a few options:

  • talk to the admin of your Provider and see what he can do to open port 22
  • change the port your VPS ssh server is listening to a non blocked port
  • use the console of your VPS if available. Usually this is accessed from the website and with a java or ajax connecting console directly to your server.

Anyways, you'll have to connect using the 3rd option to be able to change the listening port for option 2 unless you can have your VPS provider to do this for you.