SSH connection drops in 5 minutes

Hi, Here is the issue: Any SSH connection to this server drops in 5 minutes.

# date
Wed Jul 18 17:11:27 GMT 2012 (Note: use GMT)

# grep Alive /etc/ssh/sshd_config
#TCPKeepAlive yes
ClientAliveInterval 60
ClientAliveCountMax 100

# ssh -V
OpenSSH_4.3p2, OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008

# uname -a
Linux hostname 2.6.18-308.el5 #1 SMP Fri Jan 27 17:17:51 EST 2012 x86_64 x86_64 x86_64 GNU/Linux

puttyputty -> Connection -> Seconds between keepalives (60)

Please help and thank you in advance!

Drops even when busy, or only when idle?

Putting settings into /proc/ for keepalives isn't too great an idea since it will apply to all your connections, even ones which don't need it, increasing your bandwidth a lot. Getting the right combination of settings to do what you actually want can be tricky, too.

I usually use libkeepalive when I need to connect to something with obnoxious timeouts. It can be applied to a single program, works for anything(intercepting socket calls to impose default keepalive settings when a program creates a TCP socket) and is relatively easy to configure.

Only when idle.

Thanks.

Far too many programs have broken keepalive settings since that's something extremely difficult to test. :slight_smile: libkeepalive is something I know works. Good luck.

1 Like

libkeepalive is a 3rd party application. Thank you for the introduction. For this I gave you a Thank.

I've tried the following way, but still got kicked out a few minutes after logon:

sshclient# ssh -o ServerAliveInterval=60 user@sshserver

Even better -- it's a free third-party application, of less than a hundred lines, which actually works and works very well, for any application at all.

Linux is a third-party kernel, by the way.

Keepalive settings in application software tend to be ignored, unimplemented, buggy, broken, or otherwise not abided by as you've just discovered, which is why I skipped straight to a method which works better than a placebo.

1 Like

I've made some progresses. Now if I ssh to the server as root (not a good practice I know), the session will last forever without dropping. However, if I ssh to the server as a regular user, the session will be dropped in 3 minutes.

How??

Check the TMOUT variable. Maybe someone set your shell sessions to time out on purpose.

I did and found no problem:

I also copied root's .bash_profile and .bash_logout to the user's home.

What make it different between root and regular users on session termination? I really don't understand.

Thank you!

Nothing, really.

Perhaps there is a cron job or something killing rogue non-root ssh sessions?