In normal work, the Windows system uses more, many colleagues around the computer to do some personalized settings, such as the automatic lock screen after a period of time, automatically turn off the screen, automatically log off the current login and so on. This can be done under Windows, so can it be done under Linux? After a period of groping, I found 2 methods to achieve Linux under the inactive user login for a period of time after the automatic logout operation, share to everyone.
Method one, by modifying the. bashrc or. bash_profile file to implement
implemented by modifying the. bashrc or. bash_profile file in the home directory. These two files select one of the following lines at the end, as follows:
[GeekDevOps@GeekDevOps /]$ cd ~[GeekDevOps@GeekDevOps ~]$ echo "TMOUT=90">>.bashrc [GeekDevOps@GeekDevOps ~]$ source .bashrc
In the above code we select the. bashrc file, and if you select. Bash_profile, then the same procedure. Above we set the user automatic logout time is 90 seconds, after 90 seconds the screen displays as follows:
[[email protected] ~]$ wait for input timeout: auto logout connection closing. close. Connection closed by foreign host. disconnected from remote host (10.1.1:22) at 16:38 :48. /span>
Method Two, by modifying the SSH configuration file to achieve
SSH is our most commonly used in Linux system tool, by modifying the SSH configuration file/etc/ssh/sshd_config We can also achieve time-out automatic logout function, as follows:
[root@GeekDevOps ~]# vim /etc/ssh/sshd_config
Find the following two lines:
#ClientAliveInterval 90#ClientAliveCountMax 3
Remove the comment and modify the following number:
ClientAliveInterval 90ClientAliveCountMax 2
After saving exits, restart the SSH service.
[root@GeekDevOps ~]# systemctl restart sshd
This method automatically logs out for all users except root, which is logged in for 90 seconds. The first line indicates that it is detected every 90 seconds, and the second line indicates that 2 inactivity is detected and the connection is disconnected.
Turn from: 79163504
Two methods to implement the Linux inactive user login timeout after the automatic logout