ssh: connect to host port 22: No route to host [duplicate]
Hope you are doing well today!
I started using Linux a few months ago and am pretty much new into Linux and networking.
I am using Ubuntu 20.04 2.0 LTS and installed kubuntu on a friend of mine a couple of weeks ago.
I was with 20.04 recently but decided to upgrade to 2.0. My SSH was working just perfect before upgrading the distro, but now it's not connecting anymore.
I was able to connect from my phone to my laptop with SSH before, but not anymore. I also cannot connect from my laptop to other devices using SSH. My friend and I want me to get into his server using SSH, but when I try to connect to him, I receive the following as an output: ssh: connect to host port 22: No route to host
After receiving the error above, I tried to ping his network just to make sure it's working and received the following after pinging: Destination Host Unreachable
Is the issue on my side or does he need to do any configs on his side?
Any assistance would be appreciated!
Thank you for your time!
42 Answers
you have a connectivity problem that is why you get the message "Destination Host Unreachable". Also the message "no route to host" points to the same problem, you internet connectivity. ping google.com or 8.8.8.8 to make sure your connectivity is Ok, if it works then you can check your friend's IP address is Ok or whether ssh connectivity is allowed on port 22 of his device. That is the little I know, hope it helps in finding a solution
No route to host is a common new-ssh-user network error.
Simplify: Test that your ssh client can connect to the server on the same local network. This is how you test that the ssh server is working properly, and how you best troubleshoot problems with logins, passwords, and keys.
Once you can connect on the LAN, stop making changes to the server! Everything after this point is networking that is done on the client or the router. Don't break your server.
Test that your remote ssh client has connectivity. You should be able to ping a known working server on the internet. (Example:
ping -c4 8.8.8.8).Most amateur and household local networks use a router to connect to the wider internet.
- Example LAN IP 192.168.1.5 (output of
ip addr) - Example WAN IP 205.123.456.789 (web browser: )
The WAN IP is really the router IP address.
Test that your remote ssh client can ping the ssh server's router. Since the ssh server is behind a router, you won't be able to ping the server directly.
- Example LAN IP 192.168.1.5 (output of
Set up port forwarding on the server's router. This require logging into the router and changing it's settings. Inbound ssh packets on port 22 (or whatever port you choose) must be forwarded to the server's LAN IP address. Make NO changes to the client's router.
On your remote ssh client, connect using the WAN IP address, not the LAN IP address:
ssh -p 22 me@205.124.456.789Household WAN IP addresses change. If you still get
no route to host, then double check your ssh server's LAN and WAN IP addresses.Some ISPs block port 22. Try using a different port. Remember to change the listening port on the router, not on the server.