Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question
    
Please don't cross-post. The AliveInterval is something you use to keep connections open, not to close them. –  Mat Dec 5 '13 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 –  Rajan Pathak Dec 5 '13 at 11:51
    
"... unresponsive ..." is the key word there. –  Mat Dec 5 '13 at 11:52
    
@Mat when I use this setting ClientAliveInterval 10 ClientAliveCountMax 0 and left ssh connection idle ,it just closed after 10 seconds. –  Rajan Pathak Dec 5 '13 at 12:29
    
What exactly do you want to do? Disconnect users after 30 seconds no matter what they are doing? –  peterph Dec 5 '13 at 14:55

1 Answer 1

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

share|improve this answer

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.