SSH – Enable Auto-Logout of Interactive SSH Logins

linuxopensshsshsshd

I have requirement where I want my ssh seesion to target will logout after one hour,but currently leaving an ssh session to target board idle does not get auto logout after one hour.

Below is what is set in tagets sshd_config file

ClientAliveInterval 15

ClientAliveCountMax 4

So what changes I need to do so that my ssh session gets logged out after hour if it remains idle.

Best Answer

I already encountered situations where ClientAliveCountMax prevents the connection to be disconnected. I would advise the following settings:

# ClientAliveInterval is in seconds
ClientAliveInterval 3600
ClientAliveCountMax 0

This will close the connection after 1 hour if idle.