Linux / UNIX Automatically Log BASH / TCSH / SSH Users Out After a Period of Inactivity
2012-03-31 02:57
531 查看
My development and testing webserver is used by over 100s of users. These users login from Windows XP, Linux, Mac OS X system via ssh. How do I set or automatically log users out after a period of inactivity under CentOS Linux server to improve server security and save some resources?
You can configure any Linux system to automatically log users out after a period of inactivity. Simply login as the root user and create a file called /etc/profile.d/autologout.sh, enter::
Append the following code:
Above script will implement a 5 minute idle time-out for the default /bin/bash shell. You can also create tcsh version as follows:
Append the following code:
Find ClientAliveInterval and set to 300 (5 minutes) as follows:
You can configure any Linux system to automatically log users out after a period of inactivity. Simply login as the root user and create a file called /etc/profile.d/autologout.sh, enter::
# vi /etc/profile.d/autologout.sh
Append the following code:
TMOUT=300 readonly TMOUT export TMOUTSave and close the file. Set permissions:
# chmod +x /etc/profile.d/autologout.sh
Above script will implement a 5 minute idle time-out for the default /bin/bash shell. You can also create tcsh version as follows:
# vi /etc/profile.d/autologout.csh
Append the following code:
set -r autologout 5Save and close the file. Set permissions, enter:
# chmod +x /etc/profile.d/autologout.csh
Dealing with ssh clients
SSH allows administrators to set an idle timeout interval. After this interval has passed, the idle user will be automatically logged out. Open /etc/ssh/sshd config file, enter:# vi /etc/ssh/sshd config
Find ClientAliveInterval and set to 300 (5 minutes) as follows:
ClientAliveInterval 300 ClientAliveCountMax 0Save and close the file. Restart sshd:
# service sshd restart
相关文章推荐
- iOS perform action after period of inactivity (no user interaction)
- BASH Shell change the color of my shell prompt under Linux or UNIX
- dotfiles for linux/unix users automatically! (python Vim IDE)
- BUG:upstream timed out (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected
- Linux下hs_err_pid.log错误Out of Memory Error
- Oracle 10.2 流复制问题(四)—— ORA-01341: LOGMINER OUT-OF-MEMORY in Oracle Streams
- 【LINUX下使用ssh登录后bash的命令操作log】
- 75.Your test database is configured to run in NOARCHIVELOG mode. One of the data files in the USERS
- Bash/KSH/SH Shell: Find The Length Of a String On a UNIX, Linux, BSD, and OS X
- HowTo: Bash Extract Filename And Extension In Unix / Linux
- Autogrow of file '******' in database '******' was cancelled by user or timed out after ****** milli
- linux内网SSH,SCP登录其他服务器Add correct host key in /root/.ssh/known_hosts to get rid of this message
- How to restore ASM based OCR after complete loss of the CRS diskgroup on Linux/Unix systems [ID 1062
- 4 Ways of Executing a Shell Script in UNIX / Linux
- A friends walks in when the rest of the world walks out
- ssh到linux时,变成 bash-4.1 的办法
- linux mmap出现Address 0x7ffff7ff6000 out of bounds>
- 论文笔记:A LOGICAL CALCULUS OF THE IDEAS IMMANENT IN NERVOUS ACTIVITY
- 64位 linux 中 oracle 11g dbca 报 out of memory 错误
- Exception in thread "http-bio-8080-exec-13" java.lang.OutOfMemoryError: PermGen space