SSH timeout server not responding is a frustrating error message for users.
And, when it happens while making important server changes, things go for a real toss !
Usually, the SSH connection timeout occurs due to bad server settings, wrong IP hosts, firewall restrictions, etc.
At Bobcares we often get requests to fix ssh timeout error, as a part of our Server Management Services.
Today, let’s discuss the ssh timeout error and see how our Support Engineers fix it.
What is SSH timeout in a server?
SSH is a secure way to login to a remote machine over an insecure network. For instance, network services like login, remote command execution, etc. can be securely executed via SSH.
Usually, the session timeout is an event that indicates an inactive user. This event changes the status of an inactive user session to invalid. And the SSH user will get the message ‘ssh timeout server not responding’.
The typical error message appears as.
ssh: connect to host xx.xx.xx.xx port 22: Connection timed out
Here xx.xx.xx.xx denotes the host IP that the user is trying to connect.
For users making important server changes, this timeout can be annoying.
A few reasons for this timeout error include incorrect host IP, firewall setting, port block, etc.
Causes and fixes for an SSH timeout error
So far, we saw the error in detail. Now let’s see the causes for the error and discuss how our Support Team fixes it for our customers.
1. Wrong hosts
Usually, SSH timeout errors show up when users give the wrong SSH hostname or outdated IP address.
Therefore, our Support Team begins checking by verifying the SSH connection details. We ensure that the users use correct host IP addresses, user details without any typo errors.
2. Change in SSH port
Some customers may change the default SSH port 22 to some custom port in their server. Then, when the customer tries to connect, the ssh timeout error shows up.
To check the SSH port we use the command,
netstat -l | grep ssh
Thus, our Support Team will be able to find the port at which SSH runs. Further, we check the SSH configuration file at /etc/ssh/sshd_config and verify the port parameters.
3. Firewall restrictions
Many times, firewall settings can cause timeout errors while trying to connect using SSH. This can be due to some server-side settings or port blocks in some networks.
So, our Support Engineers check the firewall settings and make sure that it does not cause the ssh connection timeout.
For instance, we check the iptables to see if there are any IP restrictions.
iptables -nL | grep xx.xx.xx.xx
We remove the IP restrictions to fix the error.
How we can avoid ssh timeout?
So far, we saw how we fix the ssh timeout error. As part of our proactive server administration, our Server Administrators avoid ssh connection timeout by changing a few configuration settings. Let’s take a look at them now.
1. Client-side settings
Firstly, let’s see how our Support Engineers change the session timeout on the client-side.
To avoid session timeout for a user, we edit the ~/.ssh/config file.
So, in this configuration file, we add the following code.
Host *
ServerAliveInterval 120
ServerAliveCountMax 2
This indicates that a null packet is sent to the server every 120 seconds twice to keep the session alive.
2. Sever-side settings
Similarly, server-side settings also affect all client connections.
Hence, to make such a change, we edit the configuration file. In the /etc/ssh/sshd_config file we add the following.
KeepAlive yes
ClientAliveInterval 120
ClientAliveCountMax 2
These settings make the server send a null packet every 120 seconds. It shows a timeout after trying for two times.
[Still having trouble in fixing SSH timeout error? – We will help you.]
Conclusion
In short, ssh timeout server not responding error occur due to bad server settings, wrong host address, firewall settings and so on. Today, we discussed the fixes and saw how our Support Team proactively avoid timeout errors.
0 Comments