Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

4 Answers 4

up vote 2 down vote accepted

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.

share|improve this answer

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.

share|improve this answer

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.

share|improve this answer
    
Great suggestion, but echo $TMOUT returns nothing. –  Leopd Jun 8 '11 at 17:54

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
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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