SSH is the secure shell protocol that assists the secure communication over an unsecured network. It is utilized to connect the server on remote bases. Like other operating systems, the ssh command is supported in Linux to send and receive packets between host and server. However, an error “ssh no route to host” comes across during server connection.
This guide will enlist the possible reasons and the solutions to the error “ssh no route to host”.
The content carried out in this guide is as follows:
- Reason 1: Server Services Down
- Solution: Check Services via ping Command
- Reason 2: Firewall Blocks Specific Port
- Solution: Update Firewall Rules for Port 22
- Reason 3: Inactive SSH Services
- Solution: Install OpenSSH and Check Services
Let’s start this guide.
Reason 1: Server Services Down
One of the most common reasons for the error is the downgrading services of the remote server. Therefore, the network administrator faces an error when the system does not access the remote server. For this, the system cannot access the target/remote server.
Solution: Check Services via ping Command
To encounter the error, check the running services of the server through the “ping” command. If the packet is successfully sent, ping is not the cause of this error:
$ ping 127.80.1.12
The output shows that packets are continuously sent to the server with a millisecond difference.
Reason 2: Firewall Blocks Specific Port
Another possible reason for generating the error is the firewall blocking the connection request on Port 22. Therefore, the firewall rules must be updated by configuring the specified port responsible for transferring packets to the remote server.
Solution: Update Firewall Rules for Port 22
The error can be tackled by configuring the firewall rules for Port 22. For this, the “ufw” supports the framework to modify the firewall configuration through the terminal. To allow the permission on port 22, execute the below script:
$ sudo ufw allow 22/tcp
You can utilize the firewall utility by adding port 22 over the TCP protocol through the terminal. For this, execute the below script:
$ firewall-cmd --permanent --add-port=22/tcp
The output shows that firewall rules are successfully updated.
Reload the services that are applied to update the firewall rules. For this, execute the below script:
$ firewall-cmd - - reload
Reason 3: Inactive SSH Services
The inactive services of SSH may cause an error in establishing a connection to the server for sending and receiving packets. It can be encountered to install the specific utility for routing.
Solution: Install OpenSSH and Check Services
The installation of OpenSSH is one of the possible solutions to handle the generated error. OpenSSH is a network utility that provides a secure environment for communication between host and server. To install the utility, execute the below script:
$ sudo apt install openssh-server
Check SSH Services
After the installation is complete, check the ssh services either active or not; run the following script:
$ sudo service ssh status
Now, you can confirm that services of OpenSSH have been activated through the terminal.
Verify Execution of SSH Command
To access the remote server, the ssh command is utilized with the “username” and allocates an IP address “127.80.1.12” as verified below:
$ ssh [email protected]
That’s all from this guide.
In Linux, the “ssh no route to host” error can be fixed through the “ping” command, updating firewall rules for Port 22, and installation of the “OpenSSH” utility. These possible solutions can encounter the error generated by downgrading server services, blockage of firewall ports, and inactive ssh services. This guide has provided all possible solutions to resolve the error in the Linux system.