What is this auto logout?
Ans : Auto logout is a concept to force user to logout from the remote server. If the open session to remote server is idle for a given time. This is a security measure Linux administrators follow for terminating idel sessions to remote servers.
Why actually we require auto logout?
Ans : As a security measure, This is a good practice to set this, because its not a good idea/practice to keep open terminal idle for longer duriations.
How to accomplish this for a system wide setting?
Ans : This can be achieved by two ways.
1. Open /etc/profile and append TMOUT variable. See my below example
Export TMOUT=600 # 10 minutes in seconds
typeset -r TMOUT
This will set time-out to 600 sec(ie 10mins) and I have given typeset -r which read-only and will not allow users to change this. Save the file and exit.
2. By creating /etc/profile.d/sessiontimout.sh file then keeping above mention entries in it.
Export TMOUT=600 # 10 minutes in seconds
typeset -r TMOUT
Now save and exit the file
As this is a script we have to change the permissions too.
#chmod +x /etc/profile.d/sessiontimout.sh
How to accomplish this forĀ individual users?
Ans : We can edit ~/.bashrc file as given below.
Open ~/.bashrc file for a given userĀ and write below two line in to it.
TMOUT=600
export TMOUT
Save the file and source it as given below.
source ~/.bashrc
This change can be seen only for that user. Please share your thoughts on this, if you know better option to do it.
this set up is for all the users, how to do it for a single user
Hi Arun,
You can keep below lines in your ~/.bashrc file(For every user, they have their own .bashrc files).
TMOUT=600
export TMOUT
Save the file and source it.
source ~/.bashrc
Hope this helps and I updated the post to include this as well.
Thanks,
Surendra.