Welcome to Linux Screw! If you're new here, you may want to subscribe our RSS feed.
I’ve noticed that when I keep ssh sessions that I opened before untouched for some period of time (like 30 minutes) they become frozen and as a result I have to close ssh terminal and start a new connection. To prevent such situation I found several tips:
1) Start some utility updating the screen before leaving ssh session untouched. I usually use watch -n 1 ‘date’ that shows current date every second. Other simple way is to send icmp requests to some host, e.g. ping google.com.
2) Increase ssh session idle time by
echo “7200″ > /proc/sys/net/ipv4/tcp_keepalive_time
I’ve checked these tips with Fedora Core, CentOS, Debian and Ubuntu but I’m completely sure that it applicable also for other Linux distributions. First tip (ping) can be used in Unix also.
You may also be interested in:
Secure shell (ssh) connection without password
Keep ssh session saved (Unix “screen” utility)
Moving Linux to remote server (over ssh via third server)

I’ve been trying to deal with the freezing of ssh sessions on a debian etch box (kernel:2.6.18-5-686) for a while and have not had much luck.
Sessions freeze after just a few minutes of inactivity - even if I am sitting in pine.
echo “7200″ > /proc/sys/net/ipv4/tcp_keepalive_time
did not make any difference. Actually, 7200 was already stored in that file.
This is a new problem which I did not have before upgrading from Mandrake 10 to Debian.
Under Mandrake, idle sessions would get logged off (as opposed to frozen) after a reasonable interval.
Can you suggest other things that I could try?
Thanks!
P.E.
Hi P.E.,
Here are some directives of SSH server’s sshd_config that are related to session timeouts:
ClientAliveInterval
TCPKeepAlive
KeepAlive
Here are some directives of client’s ssh_config:
ServerAliveInterval
TCPKeepAlive
sshd_config and ssh_config are usually located at /etc/ssh directory of server and client.
These directives are are widely described by
man sshd_configandman ssh_configbut default settings may be different from distro to distro.P.S. As for me, I found first tip of current post the most useful as it works brilliantly at every *nix machines I was working with via ssh (just make
ping 127.0.0.1when you’re going to leave ssh terminal untouched for some time).P.P.S. Another nice workaround is to use
screenutility. In case you use it you can be sure that you won’t loose any output of commands you’ve started. Here is little notice how to use it.Good luck!