Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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
add comment

2 Answers 2

up vote 2 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
add comment

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
add comment

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.