Ssh – Set up ssh client to disconnect after inactivity

ssh

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

Best Answer

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