1.针对所有用户
vim /etc/profileexport TMOUT=900 # 设置闲置时间为15分钟,单位为秒;如果没有此行则直接添加进去
source /etc/profile 立即生效
2.针对特定用户(如针对tenguwang)
cd /home/tenguwang/vim .bash_profile 或 vim .bashrcexport TMOUT=900
source /home/chen/.bash_profile 或 source /home/chen/.bashrc
3.通过修改ssh的配置文件来实现
vim /etc/ssh/sshd_config找到以下两行:ClientAliveInterval 60ClientAliveCountMax 5
systemctl restart sshd
这种方法对除了root之外的所有用户都是60秒登录超时,自动登出。第一行表示每60秒检测一次,第二行表示检测到5次不活动就断开连接。
