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):
If you are the server then edit sshd_config and changed:
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
/etc/ssh/sshd_config. If you have laggy network connection these settings could cause disconnects too.
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.