Junior — Middle
What steps should be taken if an SSH connection stops responding or hangs?
sobes.tech AI
Answer from AI
If an SSH connection stops responding or hangs, you can take the following steps:
- Check the network connection — ensure that the client and server are accessible over the network (ping, traceroute).
- Try opening a new SSH connection to determine whether the issue is with a specific session or the server.
- Use the
ssh -voption to enable verbose output and diagnostics. - Check the server load and status (for example, using
top,htop), as the server might be hung or overloaded. - If you have access to the server through another method, restart the SSH service (
sudo systemctl restart sshd). - Check the timeout and keepalive settings in the SSH client and server to prevent disconnections due to inactivity.
Example command with verbose output:
ssh -v user@host
This will help identify at which stage the hang occurs.