1

I have a question about ssh configuration. In a test machine I've set:

# TCPKeepAlive yes
Protocol 2 
ClientAliveInterval 60 
ClientAliveCountMax 0

And if I wait a minute, session does not close.

I've checked sshd_config man page and I didn't find more options to change.

  • I've tried with 0, 1 and 2 and it does not work :( – jask Dec 13 '17 at 14:53
  • What are you doing on the client side to prevent it from responding to the client alive messages? – B Layer Dec 13 '17 at 14:57
  • Good question. I've started ssh session and I'm waiting 1 minute in order to close it automatically. I don't know if it is the best way to reproduce it. I don't do any action, only waiting. – jask Dec 13 '17 at 15:04
  • 1
    I did finally find some documentation that says you interpreted the use of 0 correctly. The strange thing is that it is not mentioned in the man page not a couple other primary doc locations. Also, it's not working for you. Hopefully someone with more insight will come along. – B Layer Dec 13 '17 at 15:46
  • 1
    to validate, you need to make sure that your client is actually, truly idle, and not sending any data over the encrypted channel. – Tim Kennedy Dec 13 '17 at 16:05
2

ClientAliveInterval is the number of seconds after which, if no data has passed the encrypted channel, the server will send a keepalive message.

ClientAliveCountMax is the maximum number of keepalive messages the server will send to the client, without receiving a response, before it disconnects the client.


ClientAliveInterval defaults to 0 which indicates that these keepalive messages will not be sent at all. Yours is set to 60, which would indicate you want to close idle sessions after 1 minute of inactivity.

However, your ClientAliveCountMax is set to 0, which (to my understanding) would disable the limit. Try setting this to 1. That should tell sshd that it should close idle sessions after a single iteration of 60 seconds idle.


If you want to close the connection after 10 idle minutes, you could set:

ClientAliveInterval 60
ClientAliveCountMax 10
  • 1
    I did a test and I've could check that if I set these parameters and I connect using Putty session closes in 10 minutes, but if I use other ssh client, for example MobaXterm it does not work. Thanks, it works on Putty :) – jask Dec 13 '17 at 18:03
  • there's a keepalive checkbox in moba, in the settings menu, on the ssh tab. otherwise, maybe it's something with the sftp browser that opens on the side. – Tim Kennedy Dec 13 '17 at 18:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.