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

The Solaris machine we do most of our development on has an annoying habit of timing out SSH sessions. Doesn't matter whether the client is my Ubuntu desktop, my Solaris desktop or my Windows desktop (putty); the common factor is the big Solaris machine.

Is there anything I can do to stop this happening? It's annoying when you take a lunch break and the terminal sessions you've got open and delicately configured are all frozen so you need to kill them all and reestablish all of your context.

share|improve this question

11 Answers 11

up vote 7 down vote accepted

Yes. Configure SSH to send keepalive packets.

share|improve this answer
    
We already have "KeepAlive Yes" in the /etc/ssh/sshd_config. It didn't have a ClientAliveInterval value though; so I've added that and we'll see how that goes. –  Andrew May 1 '09 at 6:46
1  
It's also worth noting that you can do it the other way around aswell. If you couldn't change the server config, you can get the ssh client to send the keep alive packets instead using ServerAliveInterval. –  SpoonMeiser May 5 '09 at 10:37
    
The location of that article changed. Here's the current one: forumone.com/blogs/post/quick-tip-ssh-keepalive –  John Bachir Nov 9 '10 at 3:56
    
Thanks for the update. –  Ben Alpert Nov 14 '10 at 2:52

I've found that the keepalive behaviour didn't quite work. I tried adding the ServerAliveInterval to the ~/.ssh/config script but it doesn't play nice with git.

What I've ended up doing is adding a timestamp to my 'screen' status bar. This is enough activity to keep the connection up.

share|improve this answer
    
If you want this functionality outside of screen(1), check out Spinner –  Drew Stephens Sep 6 '09 at 21:50

You can configure Putty to send keep alive packets too.

In Settings, Connection, Seconds between keepalives.

share|improve this answer

First, you need to determine if it's your shell which is logging you out or ssh. To test, ssh into your remote machine, and vi or less a file.

If a long time later you can still move around less/vi, then ssh is fine. In this case, determine what shell you are using, and disable the timeout. It's most likely the shell which is timing you out and not SSH. However, some firewalls will close idle sessions if keep alives aren't sent.

The Solaris administrator may prevent you from disabling the timeout in your shell, by making the setting read-only. This is unlikely, but possible. You can usually get around this by using a different shell.

share|improve this answer

If you run tcsh on the Solaris machine the autologout variable could be set. If you set that to 0 (set autologout=0) or unset it (unset autologout) it will stop log you out.

share|improve this answer

This may be a red herring, but try

unset TMOUT

at your shell prompt. This has certainly worked for me in the past, but I can't remember if it's restricted to certain architectures (or shells).

share|improve this answer

Type in your shell profile

export TMOUT=0

export TIMEOUT=0

share|improve this answer

If you have trouble re-configuring your shell again, you could use GNU screen. If your SSH session times out, just login again and reconnect and your shell will be just as it was.

share|improve this answer

I have always had success with 'ClientAliveInterval 300' on linux / bsd servers.

share|improve this answer

You could run top in another terminal? That should generate regular traffic?

share|improve this answer

Spinner sounds like the perfect solution to your problem. It periodically sends characters in your session to keep it from timing out.

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.