Disconnecting SSH session after idle-timeout

Hi Team

Is there a way or command to configure the SSH idle timeout? so that SSH connection will be dropped after the idle-timeout expires.
Currently SSH session stays forever and wanted to tear down as soon as idle time expires.

Blason R

Setting the TMOUT env var may help you:

# Force logout when no activity occurs, this sets the inactivity timeout to 14400 secs
# TMOUT: <...> If set to a value greater than zero, 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.
export TMOUT=3600

Put the above in /config/tmout.sh and put this as last line in your ~/.bashrc:

. /config/tmout.sh
1 Like