Activities under Linux implementation does not automatically logged out users after login timeout

Method One: by modifying .bashrc or .bash_profile file

By modifying .bashrc or .bash_profile file in the home directory. These two files will select one of the following line is added at the end, as follows:

The above code, we chose the .bashrc file, if you choose .bash_profile, then the same is true of operational processes. Above we automatically set user logout time is 90 seconds, 90 seconds after the display shows:

Method two: by modifying the configuration file ssh

ssh is our Linux system more commonly used a tool by modifying the ssh configuration file / etc / ssh / sshd_config We're also implement a timeout automatic logout function, as follows:

Locate the following two lines:

#ClientAliveInterval 90
#ClientAliveCountMax 3

Note remove, modify behind the figures:

ClientAliveInterval 60
ClientAliveCountMax 5

Save and exit, restart the ssh service:

This approach to all users except the root login timeout is 60 seconds, the automatic logout. The first line represents the detection time every 90 seconds, the second row indicates the detection of 5 to disconnect inactive.

Method three: by modifying the configuration file ssh

In the / etc / profile file, add TMOUT field, and source / etc / profile can be.

TMOUT=300
export TOMOUT

Method four: create a script

Log in as the root user, create a new file called autologout.sh of.

vim /etc/profile.d/autologout.sh

Add the following contents:

TMOUT=100
readonly TMOUT
export TMOUT

Save and exit the file, add executable permissions for it:

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

Now, log out or reboot the system. Inactive users after 100 seconds will be automatically logged out. Even ordinary users want to keep the session connection but can not modify the configuration, they will be forced to quit after 100 seconds.

Guess you like

Origin www.linuxidc.com/Linux/2019-08/159944.htm