System reinforcement-locking users

Source: Internet
Author: User

/********************************************************************* * Author  : Samson * Date    : 07/06/2014 * Test platform: *              Linux ubuntu 3.8.0-42-generic #62~precise1-Ubuntu *              GNU bash, version 4.2.24(1)-release * *******************************************************************/

In system reinforcement, users who do not need to log on should be locked so that they cannot log on to shell to execute other system actions, you can use either of the following methods to configure this function:

0. Set the shell field in the/etc/passwd file to/bin/false;

1. Set the shell field in the/etc/passwd file to/usr/sbin/nologin;


The difference between the two methods is that one can log on to FTP and the other cannot log on;

The following two configurations are tested:

0-create a new user: testfalse;


0. Modify the shell item in the/etc/passwd file as root:

Testfalse: X: 1001: 1001:,:/home/testfalse:/bin/false

Run:

[Email protected]: ~ # Su testfalse

Result: No task return value;

So what are the records of auth. log:

Jul 5 12:46:10 Ubuntu su [9785]: Successful Su for testfalse by root
Jul 5 12:46:10 Ubuntu su [9785]: +/dev/pts/1 root: testfalse
Jul 5 12:46:10 Ubuntu su [9785]: pam_unix (SU: session): session opened for user t
Estfalse by v0idp0int (uid = 0)
Jul 5 12:46:10 Ubuntu su [9785]: pam_unix (SU: session): session closed for user testfalse


1. Modify the shell item in the/etc/passwd file as root:

Testfalse: X: 1001: 1001:,:/home/testfalse:/usr/sbin/nologin

Switch the user to testfalse and execute:

Su testfalse

Result:

[Email protected]: ~ $ Su testfalse
This account is currently not available.

So what are the records of auth. log:

Jul 5 13:02:31 Ubuntu su [10700]: Successful Su for testfalse by v0id
Jul 5 13:02:31 Ubuntu su [10700]: +/dev/pts/3 v0id: testfalse
Jul 5 13:02:31 Ubuntu su [10700]: pam_unix (SU: session): session opened for user testfalse by v0id (uid = 1000)
Jul 5 13:02:31 Ubuntu nologin: Attempted login by v0id on/dev/pts/3
Jul 5 13:02:31 Ubuntu su [10700]: pam_unix (SU: session): session closed for user testfalse


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.