Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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 want to be able to automatically terminate ssh connections that are idle for more than 10 minutes.

How do I do this?

share|improve this question
up vote 6 down vote accepted

Open up terminal, Ctrl-Alt-T. Then:

  • sudo gedit /etc/ssh/sshd_config

  • Set (or modify) the following options:

    ClientAliveInterval 600
    ClientAliveCountMax 0
  • Save and exit the editor.

  • Run sudo service ssh restart

ClientAliveInterval sets the period after which, if the server sees the client as idle, it will send a "keep alive" request. If it gets no response, the client is disconnected. ClientAliveCountMax is the number of times such a keep alive is requested before disconnection. By setting it to 0, the keepalive is never sent and all clients idle for more than 10 minutes (600 seconds) are disconnected.

share|improve this answer

Edit /etc/ssh/sshd_config

sudo vim /etc/ssh/sshd_config

Add in this file the ClientAliveInterval option in seconds.

By the MAN page of sshd_config, that you can check here :

ClientAliveInterval: Sets a timeout interval in seconds after which if no data has been received from the client, sshd will send a message through the encrypted channel to request a response from the client. The default is 0, indicating that these messages will not be sent to the client. This option applies to protocol version 2 only.

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.