Linux controls User Logon locations and usage of PAM

Source: Internet
Author: User
Article Title: linux controls users' logon locations and usage of PAM. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

Control users' logon locations

The file/etc/secruity/access. conf can control the user's logon location. To use access. conf, add the following lines to the file/etc/pam. d/login:

Account required/lib/security/pam_access.so

Format of the access. conf file:

Permission: users: origins

Where:

Permission: It can be "+" or "-", indicating that the request is allowed or rejected.

User: user Name and user group name. If it is all, it indicates all users.

Origins: logon location. Local indicates local, all indicates all locations, and console indicates console. In addition, origins can also be a network.

In the next two domains, adding the distinct T means ". For example, except for the following:

-: ALL records t wheel shutdown sync: console

The root account's logon location is not controlled in the access. conf file, but is controlled by the/etc/securetty file.

Make sure that/etc/pam. d/login has the following line:

Auth required pam_securetty.so

The etc/securetty file specifies the tty device that allows root login, which is read by the/bin/login program in the format of a list of permitted names, you can edit/etc/securetty and comment out the following lines.

# Tty2

# Tty3

# Tty4

# Tty5

# Tty6

In this case, root can only log on to the tty1 terminal.

Some explanations about PAM

Warm-up:

Programs that grant user privileges must be able to perform user authentication. When you log on to the system, you must provide the user name and password, and then log on to the process to verify the validity of the login --- confirm that you are the user. There are other authentication methods besides password authentication, and the password storage methods are also different.

1. Description

A. PAM can load the target files (modules) in the RedHat Linux system. They are stored in the/lib/security directory.

B. Set Some configuration files in the/etc/PAM. conf OR/etc/pam. d/directory of the local system configuration file of the pam library.

2. # more login

# % PAM-1.0

Auth required pam_securetty.so

The root user can only log on to the system from the terminal contained in the/etc/securetty file.

Auth required pam_stack.so service = system-auth

Auth required pam_nologin.so

Provides standard UNIX nologin logon authentication. If the/etc/nologin file exists, only the root user can log on. Other users only obtain the content of the/etc/nologin file when logging on. If/etc/nologin does not exist, this module does not work.

Account required pam_stack.so service = system-auth

Password required pam_stack.so service = system-auth

# Pam_selinux.so close shocould be the first session rule

Session required pam_selinux.so close

Session required pam_stack.so service = system-auth

Session optional pam_lele.so

# Ls-l/dev/pts/1

Crw -- w ---- 1 root tty 136, 1 May 15/dev/pts/1

# Ls-l/dev/pts/2

Crw -- w ---- 1 test tty 136, 2 May 15/dev/pts/2

When a user logs in, the user changes the TTY device permission to the user's ownership. When the user exits, the user changes the TTY device permission to the root user.

# Pam_selinux.so open shocould be the last session rule

Session required pam_selinux.so multiple open

Login needs to do two things: first query the user and then provide the user with the required services, such as providing a shell program.

Generally, login prompts the user to enter the password. Then verify the password. This task is completed by Linux-PAM.

In the above example, the three required instances are used consecutively. Even if the first module fails, the verification of the three modules must be completed. This is a security consideration-this design will never let users know why they or they are rejected, or it will make it easier for them to break through certification. You can change "required" to "requisite" to modify this authentication method. If any "requisite" module is returned as a failure, the whole PAM Authentication will be terminated and other modules will be called again to return a failure.

3. pam_unix Authentication Module

Type: account; auth; password; session

Function Description: This module is an alternative to the standard UNIX authentication module pam_unix.

When used as the auth type, this module can identify the following parameters: debug, audit, use_first_pass, try_first_pass, nullok, and nodelay. The main function is to verify the validity of the user password, by default (without any parameters), the main function of this module is to prohibit users with blank passwords from providing services;

Auth required/lib/security/$ ISA/pam_env.so

Auth sufficient/lib/security/$ ISA/pam_unix.so likeauth nullok

Auth required/lib/security/$ ISA/pam_deny.so

When used as an account type, this module can identify the parameters debug and audit. This module mainly runs the task of creating the user account and password status, and then prompts the user to change the password, services and other tasks are provided only after the user uses the new password;

Account required/lib/security/$ ISA/pam_unix.so

Account sufficient/lib/security/$ ISA/pam_succeed_if.so uid <100 quiet

Account required/lib/security/$ ISA/pam_permit.so

When used as a password, this module can recognize the following parameters: debug, audit, nullok;, not_set_pass, use_authtok, try_first_pass, use_first_pass, md5, bigcrypt, shadow, nis,

Remember. This module allows you to change the password;

Password requisite/lib/security/$ ISA/pam_cracklib.so retry = 3

Password sufficient/lib/security/$ ISA/pam_unix.so nullok use_authtok md5

Shadow

Password required/lib/security/$ ISA/pam_deny.so

[1] [2] Next page

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.