SSH timeout with ClientAliveInterval and ClientAliveCountMax

  • So I'm trying to configure the SSH service to disconnect an idle client automatically after a certain amount of time.


    I added the following to the "Extra options" textfield:


    Code
    ClientAliveInterval 30
    ClientAliveCountMax 3


    Saved and disabled and re-enabled the service (also tried manually from command line: sudo service ssh restart) but doesn't seem to work. What am I forgetting/doing wrong ... ?


    Output from "w" through another ssh session:


    Code
    USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
    xxxx     pts/0    mbp.lan          21:12    1.00s  0.20s  0.00s w
    xxxx     pts/1    kodi.lan         21:25    4:42   0.08s  0.08s -bash


    Session from kodi.lan doesn't disconnect after 90 seconds. I am not using any ServerAliveInterval option on the client.


    My sshd_config file is as follows:


  • Ok, nevermind, I was wrongly assuming that a client without any user input for the specified amount of time would be disconnected. That's not what's happening though, it disconnects only when the client is inactive i.e. the computer goes to sleep without closing the connection.


    So how to close an idle connection?

  • Yes, thank you, finally figured it out now too.


    The key is setting "ClientAliveCountMax" to "0" and not some other value. Most resources were either trying to keep the connection alive and the others did not expressly state this, hence my confusion. Ah well, sometimes it's in the details.


    I think the documentation does not make this very clear, or at least I am very bad at interpreting what is in the documentation as it is implied if you read it thoroughly (5 - 10 times in my case :thumbup: ).

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!