9

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.

12 Answers 12

8

Yes. Configure SSH to send keepalive packets.

3
  • 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, 2009 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. May 5, 2009 at 10:37
  • The location of that article changed. Here's the current one: forumone.com/blogs/post/quick-tip-ssh-keepalive Nov 9, 2010 at 3:56
2

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.

1
  • If you want this functionality outside of screen(1), check out Spinner Sep 6, 2009 at 21:50
1

You can configure Putty to send keep alive packets too.

In Settings, Connection, Seconds between keepalives.

1

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.

1

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.

0

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.

0

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).

0

Type in your shell profile

export TMOUT=0

export TIMEOUT=0

0

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

0

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

-1

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

-1

Check your sshd configuration for lines like these in /etc/ssh/sshd_config:

ClientAliveInterval 600
ClientAliveCountMax 0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .