maanantai 2. elokuuta 2010

How to lock / timeout / logout an idling session in bash/screen or close an idling ssh-connection

SSH 
If you wish to close idling ssh-connections you may do so by just adding two lines into your sshd_config-file. The lines would be as followed:


ClientAliveInterval 10
ClientAliveCountMax 1


The ClientAliveInterval means seconds to wait before sending first ClientAliveCountMax. So, the connection will close after ClientAliveInterval*ClientAliveCountMax=10*1=10 seconds.

Bash

In bash (and similar) you may define an enviroment variable TMOUT, which defines idle time in seconds after which the bash session will log out. You may do so just by typing export TMOUT=300 into your bash or putting it in your .profile-file at ~/.profile.


export TMOUT=300

screen

This I love the most. By editing your screenrc (debian: in /etc/screenrc , freebsd: in /usr/local/etc/screenrc) you can define an idle time after which your active screen will go blank and lock itself up asking for your password to continue.  

So, the config goes as:


idle 900 lockscreen

where the 900 defines idle time in seconds before locking the screen up.

Ei kommentteja:

Lähetä kommentti