Thursday, April 30, 2009

Setup Automatic Users Logout After a Period of Inactivity

* For SH/BASH/TCSH


Below script will implement a 5 minute idle time-out for the default /bin/bash shell.



Step 1: Create file autologut.sh

 # vi /etc/profile.d/autologout.sh


Append the following code:


TMOUT=300


readonly TMOUT


export TMOUT


Step 2: Save and close the file. Set permissions:


# chmod +x /etc/profile.d/autologout.sh



 

*For tcsh version follow the below process


Step 1: Create file autologut.sh



# vi /etc/profile.d/autologout.csh
Append the following code:

set -r autologout 5


Step 2: Save and close the file. Set permissions:


# chmod +x /etc/profile.d/autologout.csh


 


For SSH user inactive interval we can define that in configuration file of the ssh server


Step 1 : Configure /etc/ssh/sshd_config file


# vi /etc/ssh/sshd config


Find ClientAliveInterval and set to 300 (5 minutes) as follows:


ClientAliveInterval 300


ClientAliveCountMax 0



Step 2: Save and close the file. Restart sshd:
# service sshd restart

 

No comments:

sanjay's shared items

My Blog List