10.2. About PAM Configuration Files | Red Hat Product Documentation (2024)

download

PDF

Each PAM-aware application or service has a file in the /etc/pam.d/ directory. Each file in this directory has the same name as the service to which it controls access. For example, the login program defines its service name as login and installs the /etc/pam.d/login PAM configuration file.

Warning

It is highly recommended to configure PAMs using the authconfig tool instead of manually editing the PAM configuration files.

10.2.1.PAM Configuration File Format

Each PAM configuration file contains a group of directives that define the module (the authentication configuration area) and any controls or arguments with it.

The directives all have a simple syntax that identifies the module purpose (interface) and the configuration settings for the module.

module_interfacecontrol_flagmodule_name module_arguments

In a PAM configuration file, the module interface is the first field defined. For example:

authrequiredpam_unix.so

A PAM interface is essentially the type of authentication action which that specific module can perform. Four types of PAM module interface are available, each corresponding to a different aspect of the authentication and authorization process:

An individual module can provide any or all module interfaces. For instance, pam_unix.so provides all four module interfaces.

The module name, such as pam_unix.so, provides PAM with the name of the library containing the specified module interface. The directory name is omitted because the application is linked to the appropriate version of libpam, which can locate the correct version of the module.

All PAM modules generate a success or failure result when called. Control flags tell PAM what to do with the result. Modules can be listed (stacked) in a particular order, and the control flags determine how important the success or failure of a particular module is to the overall goal of authenticating the user to the service.

There are several simple flags[2], which use only a keyword to set the configuration:

  • required — The module result must be successful for authentication to continue. If the test fails at this point, the user is not notified until the results of all module tests that reference that interface are complete.

  • requisite — The module result must be successful for authentication to continue. However, if a test fails at this point, the user is notified immediately with a message reflecting the first failed required or requisite module test.

  • sufficient — The module result is ignored if it fails. However, if the result of a module flagged sufficient is successful and no previous modules flagged required have failed, then no other results are required and the user is authenticated to the service.

  • optional — The module result is ignored. A module flagged as optional only becomes necessary for successful authentication when no other modules reference the interface.

  • include — Unlike the other controls, this does not relate to how the module result is handled. This flag pulls in all lines in the configuration file which match the given parameter and appends them as an argument to the module.

Module interface directives can be stacked, or placed upon one another, so that multiple modules are used together for one purpose.

Note

If a module's control flag uses the sufficient or requisite value, then the order in which the modules are listed is important to the authentication process.

Using stacking, the administrator can require specific conditions to exist before the user is allowed to authenticate. For example, the setup utility normally uses several stacked modules, as seen in its PAM configuration file:

[root@MyServer ~]# cat /etc/pam.d/setupauth sufficientpam_rootok.soauth includesystem-authaccount requiredpam_permit.sosession requiredpam_permit.so
  • auth sufficient pam_rootok.so — This line uses the pam_rootok.so module to check whether the current user is root, by verifying that their UID is 0. If this test succeeds, no other modules are consulted and the command is executed. If this test fails, the next module is consulted.

  • auth include system-auth — This line includes the content of the /etc/pam.d/system-auth module and processes this content for authentication.

  • account required pam_permit.so — This line uses the pam_permit.so module to allow the root user or anyone logged in at the console to reboot the system.

  • session required pam_permit.so — This line is related to the session setup. Using pam_permit.so, it ensures that the setup utility does not fail.

PAM uses arguments to pass information to a pluggable module during authentication for some modules.

For example, the pam_pwquality.so module checks how strong a password is and can take several arguments. In the following example, enforce_for_root specifies that even password of the root user must successfully pass the strength check and retry defines that a user will receive three opportunities to enter a strong password.

passwordrequisitepam_pwquality.so enforce_for_root retry=3

Invalid arguments are generally ignored and do not otherwise affect the success or failure of the PAM module. Some modules, however, may fail on invalid arguments. Most modules report errors to the journald service. For information on how to use journald and the related journalctl tool, see the System Administrator's Guide.

Note

The journald service was introduced in RedHat EnterpriseLinux 7.1. In previous versions of RedHat EnterpriseLinux, most modules report errors to the /var/log/secure file.

10.2.2.Annotated PAM Configuration Example

Example10.1, “Simple PAM Configuration” is a sample PAM application configuration file:

Example10.1.Simple PAM Configuration

#%PAM-1.0authrequiredpam_securetty.soauthrequiredpam_unix.so nullokauthrequiredpam_nologin.soaccountrequiredpam_unix.sopasswordrequiredpam_pwquality.so retry=3passwordrequiredpam_unix.so shadow nullok use_authtoksessionrequiredpam_unix.so
  • The first line is a comment, indicated by the hash mark (#) at the beginning of the line.

  • Lines two through four stack three modules for login authentication.

    auth required pam_securetty.so — This module ensures that if the user is trying to log in as root, the TTY on which the user is logging in is listed in the /etc/securetty file, if that file exists.

    If the TTY is not listed in the file, any attempt to log in as root fails with a Login incorrect message.

    auth required pam_unix.so nullok — This module prompts the user for a password and then checks the password using the information stored in /etc/passwd and, if it exists, /etc/shadow.

    The argument nullok instructs the pam_unix.so module to allow a blank password.

  • auth required pam_nologin.so — This is the final authentication step. It checks whether the /etc/nologin file exists. If it exists and the user is not root, authentication fails.

    Note

    In this example, all three auth modules are checked, even if the first auth module fails. This prevents the user from knowing at what stage their authentication failed. Such knowledge in the hands of an attacker could allow them to more easily deduce how to crack the system.

  • account required pam_unix.so — This module performs any necessary account verification. For example, if shadow passwords have been enabled, the account interface of the pam_unix.so module checks to see if the account has expired or if the user has not changed the password within the allowed grace period.

  • password required pam_pwquality.so retry=3 — If a password has expired, the password component of the pam_pwquality.so module prompts for a new password. It then tests the newly created password to see whether it can easily be determined by a dictionary-based password cracking program.

    The argument retry=3 specifies that if the test fails the first time, the user has two more chances to create a strong password.

  • password required pam_unix.so shadow nullok use_authtok — This line specifies that if the program changes the user's password, using the password interface of the pam_unix.so module.

    • The argument shadow instructs the module to create shadow passwords when updating a user's password.

    • The argument nullok instructs the module to allow the user to change their password from a blank password, otherwise a null password is treated as an account lock.

    • The final argument on this line, use_authtok, provides a good example of the importance of order when stacking PAM modules. This argument instructs the module not to prompt the user for a new password. Instead, it accepts any password that was recorded by a previous password module. In this way, all new passwords must pass the pam_pwquality.so test for secure passwords before being accepted.

  • session required pam_unix.so — The final line instructs the session interface of the pam_unix.so module to manage the session. This module logs the user name and the service type to /var/log/secure at the beginning and end of each session. This module can be supplemented by stacking it with other session modules for additional functionality.


[2] There are many complex control flags that can be set. These are set in attribute=value pairs; a complete list of attributes is available in the pam.d manpage.

10.2. About PAM Configuration Files | Red Hat Product Documentation (2024)
Top Articles
Dcnepal Main Page News
Missoula, MT Real Estate & Homes for Sale | realtor.com®
Umbc Baseball Camp
Splunk Stats Count By Hour
Instructional Resources
Nco Leadership Center Of Excellence
Nyu Paralegal Program
Archived Obituaries
Toyota Campers For Sale Craigslist
Craigslist Benton Harbor Michigan
Craigslist Pet Phoenix
Tx Rrc Drilling Permit Query
Hendersonville (Tennessee) – Travel guide at Wikivoyage
Owatc Canvas
Capitulo 2B Answers Page 40
1Win - инновационное онлайн-казино и букмекерская контора
Where does insurance expense go in accounting?
Luna Lola: The Moon Wolf book by Park Kara
Colts Snap Counts
Christina Khalil Forum
fort smith farm & garden - craigslist
Used Sawmill For Sale - Craigslist Near Tennessee
Craigslist Free Stuff Merced Ca
Vandymania Com Forums
Energy Healing Conference Utah
Aldi Bruce B Downs
Acts 16 Nkjv
Pokemon Unbound Shiny Stone Location
Pecos Valley Sunland Park Menu
Homeaccess.stopandshop
Used Safari Condo Alto R1723 For Sale
‘The Boogeyman’ Review: A Minor But Effectively Nerve-Jangling Stephen King Adaptation
Living Shard Calamity
Troy Gamefarm Prices
Does Hunter Schafer Have A Dick
Striffler-Hamby Mortuary - Phenix City Obituaries
Happy Shuttle Cancun Review
R/Sandiego
Dtlr On 87Th Cottage Grove
Lichen - 1.17.0 - Gemsbok! Antler Windchimes! Shoji Screens!
Back to the Future Part III | Rotten Tomatoes
Marcus Roberts 1040 Answers
Puretalkusa.com/Amac
Kenner And Stevens Funeral Home
How To Customise Mii QR Codes in Tomodachi Life?
Child care centers take steps to avoid COVID-19 shutdowns; some require masks for kids
Lesly Center Tiraj Rapid
Mail2World Sign Up
Blippi Park Carlsbad
Uno Grade Scale
Verilife Williamsport Reviews
Service Changes and Self-Service Options
Latest Posts
Article information

Author: Nathanael Baumbach

Last Updated:

Views: 6092

Rating: 4.4 / 5 (55 voted)

Reviews: 86% of readers found this page helpful

Author information

Name: Nathanael Baumbach

Birthday: 1998-12-02

Address: Apt. 829 751 Glover View, West Orlando, IN 22436

Phone: +901025288581

Job: Internal IT Coordinator

Hobby: Gunsmithing, Motor sports, Flying, Skiing, Hooping, Lego building, Ice skating

Introduction: My name is Nathanael Baumbach, I am a fantastic, nice, victorious, brave, healthy, cute, glorious person who loves writing and wants to share my knowledge and understanding with you.