3

In my /etc/ssh/sshd_config file I have set the below parameters:

ClientAliveInterval 10
ClientAliveCountMax 3

Now from host machine I did ssh to the my server (where I made changes to /etc/ssh/sshd_config) file. After that I restarted the ssh sevices by running:

/etc/init.d/sshd reload

I am expecting the ssh connection should be disconnected after 30 seconds but it keeps on than there for almost an hour now.

Can anybody let me know what is going wrong here?

I am using OpenSSH version 6.1.

5
  • 1
    Please don't cross-post. The AliveInterval is something you use to keep connections open, not to close them. Commented Dec 5, 2013 at 11:13
  • Thanks Mat but This page says manpagez.com/man/5/sshd_config/.If ClientAliveInterval (see below) is set to 15, and ClientAliveCountMax is left at the default, unresponsive SSH clients will be disconnected after approximately 45 seconds. This option applies to protocol version 2 only and we left our ssh conection idle for almost half an hour Commented Dec 5, 2013 at 11:51
  • 1
    "... unresponsive ..." is the key word there. Commented Dec 5, 2013 at 11:52
  • @Mat when I use this setting ClientAliveInterval 10 ClientAliveCountMax 0 and left ssh connection idle ,it just closed after 10 seconds. Commented Dec 5, 2013 at 12:29
  • What exactly do you want to do? Disconnect users after 30 seconds no matter what they are doing? Commented Dec 5, 2013 at 14:55

1 Answer 1

5

I do not think you can get what you want using ssh settings. ClientAlive* settings are meant for when the connection between the ssh client and the ssh server become unresponsive, how long either side should wait (these are obviously the client's timeouts).

Rather I'd use Bash's $TMOUT environment variable to get the shell to disconnect after a set period of time.

TMOUT  If  set  to  a  value greater than zero, TMOUT is treated as the 
       default timeout for the read builtin.  The select command terminates 
       if input does not arrive after TMOUT seconds when input is  coming  
       from  a  terminal.   In  an interactive  shell,  the value is 
       interpreted as the number of seconds to wait for input after issuing 
       the primary prompt.  Bash terminates after waiting for that number of 
       seconds if input does not arrive.

References

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.