Secure Unix shell account with auto-logout after seconds of inactivity - Idle TMOUT How to secure unix shell, how to log you out after x seconds of inactivity (Idle).
Secure Unix shell account with auto-logout TMOUT environment variable
$ TMOUT=10 ... after 10 seconds of inactivity ... $ timed out waiting for input: auto-logout
After setting the TMOUT variable to x seconds your shell will log out after x seconds of inactivity (Idle).
To have TMOUT environment variable set for all users or only for you, add to /etc/profile or ~/.profile or ~/.bash_profile the following line:
$ vim /etc/profile TMOUT=60 #or the number of seconds you want /etc/profile [+] -- INSERT --
Now press ESC and :x to save the file.
$ echo $TMOUT
$ . /etc/profile $ echo $TMOUT 60
What I did was to add TMOUT=60 to /etc/profile. After saving the file, the variable TMOUT is not set, so my shell will not log out after 60 seconds of inactivity. In order to have this working I reloaded the settings in /etc/profile (by this command: . /etc/profile - notice the space between . and /etc/profile). Then I echoed again $TMOUT variable and there it was.
$ timed out waiting for input: auto-logout
I waited 60 seconds and my shell logged out because I was idle.
This was tested on FreeBSD, Red Hat running bash. I will soon test it on AIX 5.3 running bash and ksh.
Designed and developed by Andrei Manescu. Optimized for Mozilla Firefox.
Copyright 2007 Andrei Manescu
All trademarks and copyrights on this page are owned by their respective owners. Comments are owned by those who posted them.