Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to configure my ssh client to disconnect from a particular host after some period of inactivity. I do not have root access to the server. I need to do this from the client, not the server; the user on the server is shared among multiple people.

Ideally I could do this via my ssh config file so that I can source control the file and carry it to my many home directories.

I've tried the following entry in my ssh config file (~/.ssh/config):

Host somehostname
    Hostname somehostname
    User someuser
    ConnectTimeout 60

However after I log in and wait > 60 seconds I am still connected.

I'm using:

$ ssh -v
OpenSSH_5.9p1 Debian-5ubuntu1, OpenSSL 1.0.1 14 Mar 2012
share|improve this question
I see there is some ambiguity regarding the definition of "inactivity". Could you define more clearly what you mean by "some period of inactivity"? – MadHatter Jan 15 '13 at 11:37
up vote 1 down vote accepted

As the man page for ssh_config says, ConnectTimeout

Specifies the timeout (in seconds) used when connecting to the SSH server, instead of using the default system TCP timeout. This value is used only when the target is down or really unreachable, not when it refuses the connection.

It is not the equivalent of e.g. bash's $TMOUT variable, that is, autologout from the shell when the interactive session is idle. I don't think you can do what you want, in the way you want to do it (ie, client-side).

share|improve this answer
Thanks MadHatter; I compromised by setting TMOUT. – Garrett Smith Jan 16 '13 at 14:28
Garrett, I'm glad we found a workaround that worked for you. If I may presume, local etiquette is that when you're satisfied with an answer to your question you accept it by clicking the tick outline next to it, which drives the SF reputation system for both questioner and answerer. My apologies if you already know that. – MadHatter Jan 17 '13 at 8:03

Several factors are in play here:

  • the sshd server's CLientAliveInterval and ClientAliveCountMax settings determine how long the client may remain unresponsive before being disconnected.
  • the client's ServerAliveInterval and ServerAliveCountMax settings determine how long the server may remain unresponsive before the client will disconnect.

You could alter the Server*-related settings for your client, but that would not override the Client* settings on the server, and since both client and server will send a keepAlive message to each other at the set intervals, you'd have to change the setting on the server as well.

share|improve this answer

Your Answer


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.