Linux – ssh session dies after three hours on inactivity

linuxssh

I usually leave my PuTTY terminal window open during the day and lock the screen when I go to lunch or leave to go offsite. Lately though when I come back, my ssh session had died. Even though I use the keep alive from within PuTTY and have the keep alive in the sshd_config, it still occurs.

ClientAliveInterval 30
TCPKeepAlive yes
ClientAliveCountMax 99999

And in the auth log I saw:

Jun 18 15:31:52 blarg sshd[6830]: pam_unix(sshd:session): session closed for user jonathan

I don't have a TMOUT value set in /etc/profile

Any advice is appreciated.

Best Answer

Since you're using putty there are some things you can actually do right there in the client.

Open putty and in the options panel load the session definition that you're using for that saved connection.

Under connection change the fiend "Sending null packets to keep sessions active" from 0 to something else (this is in seconds, so 1800 is 30 minutes)

Check "Enable TCP keepalives" (this isn't in old versions of putty, update if you don't have it) Save your session.