Article title: Linux module verification (1 ). 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.
Today, more enterprises need to support desktop Linux users, especially those employees named senior users. Linux was once an out-of-the-box platform. Although it is compatible with a range of network and service verification and access mechanisms and can share files with Microsoft Windows, Unix, Apple Macintosh and other platforms, this interoperability is not a very important factor.
The situation is changing. For Linux users in the enterprise environment, securely sharing files with other Linux users and Windows users still means remembering a set of passwords for Linux and a set of passwords for other platforms. But now there is a better way: you can configure the system as a Linux user to obtain security verification based on Windows NT Domain. In this way, the user does not need a Linux account and another NT Domain account. This will simplify the daily work of network administrators and make advanced users more satisfied.
Verification and account management
Authentication is the process in which the system confirms the user identity. Access control determines what is allowed after verification. Verification is often associated with the account. An account is generally a series of information related to a unique identifier. This information usually includes data that is required to allow people to use system resources. For example, it provides the location of the user's personal file or the user's real name. It may include environment variables and resource limits. We mainly focus on verifying services and protocols.
Most new Linux versions use the plug-in verification module (PAM), which is the key to flexible verification. PAM is an ASP designed to modularize the process of authenticating users to access services. Developed by Sun, it is used in the latest versions of Sun Solaris, ibm aix, HP HP-UX and Apple Mac OS X, but is most widely used in combination with a variety of free operating systems, including Linux (especially Red Hat, Debian, and SuSE), FreeBSD, and NetBSD.
PAM for Red Hat
We will use the PAM system to describe how to use many verification resources for verification. But first, you may want to outline the PAM installed on Red Hat Linux 7.2 (the same technology should be applicable to various systems that can recognize PAM ).
Any service can be verified using PAM. The service only represents another name for the app to be verified by the user, such as login, FTP, and POP. Note: To use PAM, you must write the service specially. On Red Hat 7.2, PAM is used for all applications for verification. By checking whether the PAM Library (libpam) is used, you can check whether a specific executable program (such as the login used by the remote login service to check the user's identity) can use PAM, enter the command shown in the "PAM database check. Note: The second line refers to libpam.
PAM database check
However, the problem is slightly complicated: even if an application can pass PAM verification, it does not mean this is not necessary, and the application can use this function as a configuration option. Both Samba and Apache provide this function, but PAM is not necessarily required.
For each service, there is a file in the/etc/pam. d/directory. This file contains the rule for how the service obtains authentication and account information, that is, instructions, one rule per line. The "PAM service configuration sample" figure shows the file content.
PAM service configuration sample
The module in the third column is the library that can recognize PAM, and it can implement some verification mechanism. The fourth optional column provides the verification module variable. Changes are Module-specific, that is, they vary with modules. A program is executed to determine whether the rule permits or denies access.
PAM has four modules: auth, account, password, and session ). Auth indicates that this line is required if the service tries to verify the user. If the service requires account information such as userid, the account is used. If the service needs to change the user's password, it needs to use the password. The session is used by the service just before the user logs on and after the user exits. This facilitates the generation of audit logs, but can also be used to establish various environmental parameters or to install a network disk drive. Each module is allowed to appear multiple times, but in order, unless one row contains the requisite control flag.
There are four control flags: requisite (required), required (required), sufficient (sufficient), and optional (optional ). Requisite indicates that if this rule fails, access is denied immediately. Required indicates that if the rule fails, access is denied, but the other rules will be used for such modules. Sufficient indicates that access is allowed if the rule succeeds, but if it fails, it is returned to another rule. Optional indicates that the results of the rule are ignored unless such modules have no other rules. Optional is usually used for additional configurations unrelated to the verified user (in this case, we do not care whether the configuration fails ).
These control signs may be ambiguous. For verification, it requires the pam_unix PAM module. The variable element of this module allows a blank password, indicating that the system uses the MD5 password hash instead of the simple Unix crypt () hash, and uses the shadow password system. This is the only module for verification, so it has the final decision to allow users to log on.
The pam_unix module uses the account information again. It is marked as sufficient, so if the module can determine the user account, it will stop processing. If it fails, the PAM system continues and tries the next account rule. This is marked as required and uses the pam_deny module. This module always denies access, so if the first rule cannot determine the user's account information, the user will be denied access. The password change example is similar to the account information example.
As for determining the session requirements, there are two required rules in the last example. Both modules must be correctly executed to allow user sessions.
The PAM module is located in the/lib/security/directory on Red Hat Linux 7.2. Some modules have multiple functions because they can provide mechanisms for more than one type of modules. Others only provide a mechanism for a single type. For greater flexibility, the pam_stack module provides a way for system administrators to configure multiple services for unified verification. This module is widely used in Red Hat Linux 7.2 (see "default logon configuration ").
Default login configuration
Note: for each rule of each type, the pam_stack module is required and the service = system-auth variable is provided. This actually means "jump to system-auth PAM configuration", which can be found in/etc/pam. d/system-auth. Therefore, if the logon program tries to verify the user, it first runs the pam_security module and checks to ensure that the user logs on to the trusted console (the logon program usually uses a plaintext password ). In this case, it will jump to the configuration put in/etc/pam. d/system-auth, as shown in "default system verification configuration.
Default system verification configuration
Services that use this system verification configuration for verification will first run the pam_env module to create various environment variables or check certain prerequisites. Because pam_env is marked as required, the system must report the success (normally, unless there is a catastrophic problem, such as the loss of the user's main directory ). The service then runs the pam_unix module and provides traditional verification similar to Unix/etc/passwd. Pam_unix is marked as sufficient. if the configuration returns a successful result, PAM recognizes that the user has passed the verification. Otherwise, the system will enter the pam_deny module that is always inaccessible.
Services that use this system verification configuration to obtain account information will also run pam_unix, but this time is to determine the user name, user ID number, group membership, and other traditional information similar to Unix/etc/passwd. This module is marked as required, but it belongs to required by default because it is a unique account line.
The service that uses this system verification to configure and change the password first transfers the expected password to the pam_cracklib module, which checks the password strength. Because it is marked as required, if the module rejects the password, the service will be banned from changing the password. Later, the password is expected to be passed to pam_unix, which will update the traditional Unix/etc/passwd file. If this operation fails, the password cannot be changed.
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