Two methods to implement the Linux inactive user login timeout after the automatic logout

Source: Internet
Author: User

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 
    • 1
    • 2
    • 3

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>         
    • 1
    • 2
    • 3
    • 4
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
    • 1

Find the following two lines:

#ClientAliveInterval 90#ClientAliveCountMax 3
    • 1
    • 2

Remove the comment and modify the following number:

ClientAliveInterval 90ClientAliveCountMax 2
    • 1
    • 2

After saving exits, restart the SSH service.

[root@GeekDevOps ~]# systemctl restart sshd
    • 1

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.