I'm logging into an Ubuntu 10.04LTS server from my mac using standard ssh client. My ssh sessions log out automatically after a few minutes of inactivity. Normally this is a great security measure, but sometimes it's really inconvenient. How can I disable this?


As far as I know there is no standard feature in Ubuntu that logs out ssh users that are idle. I have right now an SSH connection to a 10.04 Ubuntu computer that is well over 2 days idle.

The most common reason for this behavior I have experienced is a broken NAT or firewall between you and the server. What happens is that the entries in the state table are timed out and therefor the connection is reset unless you keep using it. Try the following:

ssh -o TCPKeepAlive=yes -o ServerAliveInterval=15 <user>@<server>

And see if you keep getting disconnected. In that case, set those in your ssh config. Note that with these settings routing errors or similar will make your connection die after 45 seconds (ServerAliveInterval * ServerAliveCountMax (defaults to 3)) So you might want to play around with the ServerAliveInterval a bit.


Is this Ubuntu box your client or your server? In any case, from my experience idle connections are often timed out by routers, rather than the remote (and almost never by the client).

You can edit your /etc/ssh/ssh_config and set this value to less than the amount of time it takes for you to time out (it's in seconds):

ServerAliveInterval 360

If you are the server then edit sshd_config and changed:

ClientAliveInterval 360

The client and server will send alive packets at those intervals thus creating activity across your connection.


Check you environment for TMOUT variable - if it has value greater than 0 then your bash session will automatically end after TMOUT seconds.

Check also TCPKeepAlive and ClientAliveInterval in /etc/ssh/sshd_config. If you have laggy network connection these settings could cause disconnects too.

  • Great suggestion, but echo $TMOUT returns nothing. – Leopd Jun 8 '11 at 17:54
  • @Leopd that means the variable is not set. Run env to get a list of all exported variables. – morgents Mar 16 '16 at 8:48

This is probably not an SSH feature but a feature of the shell you are using.

I have the following set for my .cshrc file for these type of situations.

 unset autologout

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.