Article Title: LINUXPAM verification mechanism. 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.
1. PAM Introduction
Linux-PAM (the pluggable authentication module in linux) is a shared library that allows local system administrators to select the authentication method of programs at will.
In other words, you can change the authentication mechanism you use without re-Compiling an application that contains the PAM function.
In this way, you do not need to modify the program even if you upgrade the local authentication mechanism.
PAM uses the configuration file/etc/pam. conf (or/etc/pam. d/Files) to manage the authentication method for the program. the application calls the corresponding configuration file to call the local authentication module. the module is placed under/lib/security and called in the form of loading dynamic libraries (dlopen (3 )).
When we use the su command, the system will prompt you to enter the password of the root user. This is what the su command achieves by calling the PAM module.
Ii. PAM Configuration File Introduction
1. PAM Configuration File Format
The PAM Configuration file can be written in/etc/pam. conf in the following format:
Ftpd auth required pam_unix.so nullok
Ftpd: indicates the service name, which is the authentication configuration for the service.
Required: module type. PAM has four middle module types, representing different task types.
Pam_unix.so: the module path, that is, the location of the module to be called.
Nullok: the module parameter, that is, the parameter passed to the module.
Another method is to put the PAM Configuration file in the/etc/pam. d/directory and use the application name as the configuration file name. For example:
The format of the configuration file, such as vsftpd and login, is similar to pam. conf, but the leftmost service name is missing. For example:/etc/pam. d/cups
# % PAM-1.0
Auth required pam_stack.so service = system-auth
Account required pam_stack.so service = system-auth
2. PAM module type
Linux-PAM has four types of modules, which represent four different tasks. they are: authentication management, account management, session management, and password management. A type may have multiple rows, which are called by the PAM module in sequence.
Auth
Used to identify the user's identity, for example, prompting the user to enter the password or determining whether the user is root.
Account
Check the attributes of the account, for example, whether logon is allowed, whether the maximum number of users is reached, or whether the root user is allowed to log on to the terminal.
Session
This module is used to define the operations performed before and after user logon, such as logon connection information, opening and closing of user data, and mounting a file system.
Password
Use user information to update. For example, modify the user password.
3. PAM control mark
PAM uses control labels to process and determine the return values of each module.
Required
This flag indicates that a successful value needs to be returned by the module. If a successful value is returned, the next operation of the same type will continue. If all modules of this type are executed, the failed value will be returned.
Requisite
Similar to required, but if this module returns a failure, it immediately returns a failure to the application, indicating this type of failure.
Do not perform operations after the same type.
Sufficient
If this module returns a success message, the system returns a success message to the application, indicating that this type of operation is successful. The operation after the same type is not performed. If the operation fails, the return value of this type is not affected.
Optional
The module that uses this tag will not return success or failure. Generally, a PAM_IGNORE (ignore) is returned ).
4. Module path
Module path. that is, the location of the module to be called. it is generally stored under/lib/security/. For example, pam_unix.so can appear in different types in the same module. it performs different operations in different types. this is because each module has compiled different execution functions for different module types.
5. Module Parameters
Module parameters, that is, the parameters passed to the module. Multiple parameters can be separated by spaces, for example:
Password required pam_unix.so nullok obscure min = 4 max = 8 md5
[1] [2] [3] [4] Next page