Fact-checked by Grok 2 weeks ago

Linux PAM

Linux PAM, formally known as Pluggable Authentication Modules for Linux, is a flexible that provides a standardized for -related services in and systems, enabling applications to perform tasks such as user verification, account management, password changes, and session handling through interchangeable modules. This separates authentication logic from application code, allowing system administrators to configure diverse methods—like passwords, , tokens, or centralized directories such as LDAP—without recompiling or rewriting software. Originating from ' implementation in 2.6, the concept of pluggable authentication was formalized in the OSF-RFC 86.0 specification by Vipin Samar and Roland J. Schemers in 1995, which outlined a modular approach to services. emerged in 1996 when developer Marc Ewing began implementing it in response to discussions on the linux- mailing list, with Andrew G. Morgan taking over maintenance; the first full release, Linux-PAM 0.50, arrived in early 1997, quickly adopted by distributions like . By version 0.56, it introduced service-specific configuration files in /etc/pam.d/, enhancing modularity over the original single /etc/pam.conf file. At its core, Linux PAM organizes functionality into four management groups: (verifying user identity), (checking account status and permissions), (updating credentials), and session (managing open sessions). Modules, such as pam_unix for traditional Unix authentication or pam_ldap for network-based verification, are stacked in configuration files to define control flows—requiring success, allowing failure, or including other files—for services like [login](/page/Login), sshd, and [sudo](/page/Sudo). This pluggable design supports both local and remote authentication, integrates with tools like authselect for simplified management in modern distributions, and logs activities to /var/log/secure for auditing. As of June 2024, the latest stable release is Linux-PAM 1.7.1, which includes improvements in module , dynamic loading via dlopen, and support for contemporary build systems like , ensuring compatibility across major distributions including , , and . Widely used for over two decades, Linux PAM remains a cornerstone of , powering everything from console logins to networked services while adapting to evolving threats through extensible modules developed by the open-source community.

Introduction

Definition and Purpose

Linux PAM, or Pluggable Authentication Modules for Linux, is a flexible framework consisting of shared libraries that manage authentication tasks for applications and services on Linux systems. It provides a stable application programming interface (API) for handling authentication, authorization, account verification, and session management, enabling uniform security processing across diverse programs such as login utilities and network services. The core purpose of Linux PAM is to empower system administrators to configure mechanisms without altering the source code of applications, thereby supporting a variety of methods including passwords, , smart cards, and . This approach allows for the integration of local and centralized schemes, such as those using LDAP or , in a single environment. Key benefits of Linux PAM include centralized management through configuration files, which simplifies policy enforcement system-wide, and inherent that permits easy extension via additional pluggable modules without recompiling core system components. It also facilitates the support of multiple schemes concurrently, enhancing flexibility while maintaining with applications. By decoupling authentication logic from applications through dynamically loadable shared libraries, Linux PAM ensures that tasks are handled independently, allowing developers to focus on core functionality while administrators control access methods uniformly. This separation organizes tasks into groups for , account , updates, and session handling, providing a structured yet adaptable architecture.

Historical Development

The concept of Pluggable Authentication Modules (PAM) originated from a proposal by in 1995, detailed in OSF-RFC 86.0 titled "Unified Login with Pluggable Authentication Modules (PAM)." This document, authored by Vipin Samar and Roland J. Schemers of SunSoft, Inc., outlined a framework for flexible to support unified login mechanisms, particularly for the (CDE) in Unix systems. The design aimed to decouple authentication logic from applications, allowing administrators to configure diverse authentication methods without recompiling software. The first open-source implementation of for emerged through the Linux-PAM project, with developer Marc Ewing beginning the work in 1996, debuting in 3.0.4 in August 1996. Andrew G. Morgan took over maintenance shortly after. This release marked the initial deployment of as a flexible system in a major , enabling modular handling of tasks like authentication, account verification, session management, and password updates. Linux-PAM was released under a dual license of the GNU General Public License (GPL) version 2 or later and the BSD License, promoting broad adoption. PAM's evolution drew from emerging Unix standards, notably the X/Open Single Sign-On (XSSO) specification published by The Open Group in 1997, which formalized PAM as a pluggable for services across systems. This influence facilitated PAM's integration into various distributions, including early adoption in (starting with version 2.0 in 1998), and later in derivatives like and , establishing it as a by the early 2000s. Key milestones included efforts to standardize PAM interfaces, leading to its widespread use in production environments for secure, configurable by 2000. In more recent developments, the Linux-PAM project transitioned its repository to in 2017, improving collaborative maintenance and accessibility.

Core Architecture

Management Groups

Linux PAM organizes its functionality into four primary groups, each responsible for a distinct aspect of the process: (auth), (account), (password), and session (session). These groups enable modular handling of tasks, allowing administrators to configure independently for different services while ensuring a structured approach to user verification and access control. The auth group verifies a 's , typically through methods like password entry or token-based challenges, and establishes the 's credentials for subsequent use. For example, it may prompt a to enter their password to confirm against system records. The account group then checks the validity and restrictions of the authenticated , such as verifying if the has expired or enforcing time-based access limits, like denying logins outside . The password group handles updates to tokens, enforcing policies such as minimum password length or complexity requirements during changes. Finally, the session group manages the opening and closing of sessions, performing actions like activity or allocating resources such as mounting directories. These groups operate independently, with modules within each group executing based on their , but they are invoked in a typical sequence during flows: auth first to confirm , followed by account to validate eligibility, session open for setup, and password if a change is required, concluding with session close upon logout. This sequential yet allows PAM to provide comprehensive security coverage across the entire lifecycle, from initial verification to and auditing. Within each group, modules can be for layered checks, as detailed in the stacking mechanism.

Stacking Mechanism

The stacking mechanism in Linux PAM allows multiple authentication modules to be arranged in a sequential list, known as a , within each group such as , , updating, or session handling. This arrangement enables administrators to define complex policies by processing modules in the specified order, where each module's outcome influences the overall until the stack reaches a final success, failure, or policy-defined halt. By combining diverse modules in this way, PAM achieves modular flexibility without requiring modifications to the underlying applications. Flow control in the stacking process relies on the sequential evaluation of module results, where success or failure from one module can propagate to determine if processing continues or terminates immediately. For instance, a successful outcome from an early module might satisfy the stack's requirements outright, while a failure could trigger a fallback to subsequent modules, such as shifting from a remote directory service like LDAP to a local authentication method if the primary option is unavailable. This mechanism supports hybrid policies that balance reliability and security, ensuring that authentication proceeds adaptively based on real-time conditions. Stacks are tailored to specific application service types, allowing distinct configurations for scenarios like user login versus with tools such as , where the stack might enforce different module sequences to match the context. This service-specific integration promotes redundancy by incorporating backup paths and facilitates through layered modules—such as combining verification with token or biometric checks— all without necessitating changes to the application's . As a result, PAM's stacking provides a robust for evolving needs across diverse services.

Configuration

Configuration Files

The primary configuration for Linux PAM is managed through files in the /etc/pam.d/ directory, which contains service-specific configuration files for each PAM-aware application or service. For instance, the SSH daemon uses /etc/pam.d/sshd, while the login process employs /etc/pam.d/login. This directory-based approach superseded the older single-file method, providing modularity and easier maintenance for individual services. As a legacy alternative, the /etc/pam.conf file can define global PAM rules in a monolithic format, specifying service, management type, control flags, module paths, and arguments in a single columnar structure. However, this file is deprecated in most modern distributions and is only consulted if the /etc/pam.d/ directory does not exist, as the directory method takes precedence for its flexibility. Each file in /etc/pam.d/ is organized into sections corresponding to PAM groups—such as auth for , account for , password for updates, and session for session handling—delimited by these keywords. Within these sections, rules are defined on individual lines following the syntax type [control](/page/Control) module-path [arguments], where type indicates the management group, [control](/page/Control) specifies the rule's (e.g., required or optional), module-path points to the PAM (often relative to /lib64/security/ or /lib/security/), and optional arguments customize the module's operation. Comments begin with #, and blank lines are ignored for clarity. To promote reusability and avoid duplication, PAM supports an inclusion mechanism via the include control directive, which incorporates rules from another configuration file into the current one. For example, service files may include a common configuration like @include system-auth to pull in shared authentication rules. This is particularly useful for centralizing policies across services. Distribution-specific variations exist in how common configurations are named and organized. In , , and derivatives like , a central file such as /etc/pam.d/system-auth (or /etc/pam.d/system-auth-ac in some versions) aggregates core , , , and session rules, which are then included in service-specific files; as of RHEL 8 and later (including 28+), these are managed by the authselect utility, which selects predefined profiles to generate the configurations. In contrast, and employ a set of modular files prefixed with common-, such as /etc/pam.d/common-auth, /etc/pam.d/common-account, /etc/pam.d/common-password, and /etc/pam.d/common-session, managed by tools like pam-auth-update for streamlined updates. These differences reflect packaging choices but maintain the underlying syntax and semantics.

Control Flags and Syntax

The configuration of Linux PAM relies on a structured syntax within its configuration files, where each line defines a rule for module execution. The basic format of a PAM configuration line consists of four fields: the module type (such as auth, account, session, or password), the control flag, the path to the PAM module (e.g., pam_unix.so), and optional module-specific arguments. For example, a typical line might read auth required pam_unix.so nullok, specifying authentication using the Unix module while allowing null passwords. This syntax ensures precise control over how modules are invoked and evaluated during authentication processes. Control flags determine the flow of execution and the overall outcome of a PAM stack based on individual module results. The required flag mandates that the module must ultimately succeed for the entire stack to succeed, though execution continues through subsequent modules even on failure, deferring the final decision until the end. In contrast, the requisite flag requires immediate success; a failure halts the stack execution at that point, resulting in overall failure without proceeding further. The sufficient flag allows early termination on success if no prior required modules have failed, treating the stack as successful without evaluating remaining modules; however, a failure under this flag is ignored unless earlier required modules have already failed. The optional flag has no direct impact on the overall result unless it is the only module in the stack, in which case its success or failure determines the outcome. Additionally, the include flag incorporates rules from another configuration file, effectively pulling in a set of predefined lines to modularize complex policies. PAM modules return standardized error codes to indicate outcomes, with PAM_SUCCESS (value 0) signifying successful completion of the module's task, such as valid authentication. Failures are reported through specific codes like PAM_AUTH_ERR for authentication errors or PAM_SYSTEM_ERR for general system issues, which may bind to underlying system error codes (e.g., via errno) to provide diagnostic details. These codes influence the stack's behavior according to the associated control flag, ensuring consistent error propagation across the authentication framework. Module arguments are passed as space-separated tokens following the module path, allowing customization of behavior without altering the module's . For instance, the nullok argument, when used with modules like pam_unix.so, permits access for users with blank passwords, overriding the default denial of such cases. Similarly, the try_first_pass argument instructs the module to attempt reuse of credentials (e.g., a password) from a previously invoked module in the stack before prompting the user anew, improving efficiency in multi-module setups. These arguments are module-specific and must be consulted in the relevant module's for valid options and effects.

Modules

Built-in Modules

Linux PAM includes a set of built-in modules that provide core functionality for , management, session handling, and processing, distributed as part of the official Linux-PAM package. These modules are designed to integrate seamlessly with the PAM framework, allowing administrators to stack them according to specific security policies across the four management groups: auth, , , and session. They rely on standard system files and libraries, ensuring compatibility with environments without external dependencies. The pam_unix module serves as the primary mechanism for local Unix authentication, utilizing standard system library calls to retrieve and verify user credentials from /etc/passwd and /etc/shadow files. It supports password hashing with algorithms such as , SHA-256, SHA-512, blowfish, gost-yescrypt, and yescrypt, with the default method configurable via /etc/login.defs. This module also handles account status checks, password updates, and basic session logging, making it essential for traditional Unix-based logins. For security, it employs a helper binary like unix_chkpwd to access protected shadow data without exposing it directly. To mitigate brute-force attacks, pam_faillock tracks failed authentication attempts by maintaining per-user failure lists in individual files under /var/run/faillock/, enabling more precise tracking within a defined interval, such as . It locks accounts after exceeding a denial limit, like three failures, and distinguishes itself through better support for multi-stage PAM stacks and compatibility, using stages like preauth and authsucc. For session management, pam_env enables the dynamic setting, unsetting, or modification of environment variables, drawing from sources like /etc/environment or user-specific files. It supports interpolation of existing variables and PAM items, such as PAM_RHOST for remote host details, allowing variables like PATH or MAIL to be tailored per session without altering application code. This module is typically placed last in the session stack to avoid unintended side effects on preceding modules. Resource control is handled by pam_limits, which applies user- and group-specific limits on system resources during session initialization, affecting even root users. It enforces constraints such as maximum open files, CPU time, or process counts as defined in /etc/security/limits.conf or subdirectory configurations, using system calls like setrlimit to prevent resource exhaustion. This ensures fair allocation and protects against denial-of-service from resource-intensive users. In contrast, pam_deny provides an absolute denial of access across all module types, returning failure codes like PAM_AUTH_ERR for authentication or PAM_SESSION_ERR for sessions, without any conditional logic. It acts as a secure fallback for unconfigured services or explicit , ensuring no access is granted by default. Conversely, pam_permit grants unconditional success in all management groups, setting the username to "nobody" if undefined, which simplifies testing but poses significant security risks if misconfigured in production environments. These built-in modules collectively enable flexible yet secure authentication policies when stacked within PAM management groups.

Third-Party and Custom Modules

Third-party modules extend the functionality of Linux PAM beyond its built-in capabilities, enabling integration with external authentication systems such as directory services, , and two-factor authentication providers. These modules are typically developed and maintained outside the core Linux-PAM project but adhere to the PAM API for seamless incorporation into authentication stacks. They support specialized use cases like remote user validation and enhanced security protocols, often distributed through distribution package managers or compiled from source. The pam_ldap module facilitates , , and password management against LDAP servers, allowing PAM-aware applications to verify user credentials stored in centralized directory services. It supports remote authentication by querying LDAP directories for user details, making it suitable for environments with distributed user databases. Similarly, the pam_sss module integrates with the (SSSD), which handles authentication against various backends including LDAP, , and , providing offline caching and policy enforcement for remote users. For Kerberos-based environments, the pam_krb5 module enables (SSO) by validating tickets and obtaining initial credentials during login processes. Installed as part of the pam_krb5 package, it supports services like SSH and graphical logins by performing against a (KDC), ensuring secure ticket-based access without repeated password prompts. The pam_google_authenticator module adds two-factor (2FA) support using time-based one-time passwords (TOTP), integrating with apps like for enhanced on logins such as SSH. It prompts users for a verification code after primary , supporting both TOTP and counter-based HOTP modes to protect against unauthorized access. Custom modules can be developed to address unique needs, written using the libpam library to implement PAM hooks such as pam_sm_authenticate for validation logic. Developers must conform to the Linux-PAM standard, handling the four management groups (, , password, session) and managing conversation functions for user interactions, as outlined in the official module writer's guide. These modules are compiled into shared objects (e.g., .so files) and placed in the /lib/security/ directory for use in configurations. Installation of third-party modules typically involves package managers on distributions like or , such as installing libpam-ldap for pam_ldap or the pam_krb5 package for support. For modules without native packages, compilation from source is common; for example, the pam_radius module, which enables RADIUS server authentication for network-based , is built from the FreeRADIUS project sources and configured via a servers file specifying RADIUS host details and shared secrets. These modules can be stacked with built-in ones to create hybrid authentication flows.

Integration and Usage

In System Services

PAM integrates seamlessly with core system services to manage , , and session handling for user interactions. In the daemon (sshd), the configuration file /etc/pam.d/sshd defines the stack, supporting both public key-based logins—handled initially by sshd—and password through PAM modules such as pam_unix for credential verification. This setup enables flexible security policies, including integration with the pam_faillock in the auth and phases to enforce lockouts after a configurable number of failed attempts, typically three within a 15-minute , preventing brute-force attacks. For console and access, the /etc/pam.d/ file governs the process, while /etc/pam.d/su governs the su command, each orchestrating modules that perform account checks—such as verifying expiration dates and shell validity via pam_unix—and session logging through pam_lastlog to record user activity timestamps. These configurations ensure secure local logins by stacking account management modules before granting shell access, as referenced in the broader PAM configuration files structure. Privilege escalation via relies on the /etc/pam.d/ stack to authenticate users before executing elevated commands, incorporating modules like pam_unix for password validation and often pam_tty_audit in the session phase to enable kernel-level auditing of TTY input for compliance and monitoring. complements this with its native caching mechanism, storing successful authentication results for a default 15-minute period to allow subsequent commands without re-prompting, though handles the initial credential flow. Scheduled task services like and at employ PAM through /etc/pam.d/ (and similarly for at) to authenticate job submissions, using modules such as pam_access or pam_time to restrict execution based on user groups, host access lists, or specific time windows, thereby enforcing granular controls on automated processes. For instance, pam_access consults /etc/security/access.conf to deny access to non-privileged users from certain hosts. At the service integration level, applications like sshd, , , , and at initiate PAM processing by calling pam_start() to create a context with the service name (e.g., "sshd"), followed by pam_authenticate() to traverse the stacked modules for user verification, ensuring consistent authentication across diverse entry points. This flow allows services to leverage PAM's modular design without embedding authentication logic directly.

Programming with PAM

Programming with PAM involves integrating the Pluggable Authentication Modules (PAM) library into applications via its C API, allowing developers to perform , account management, and related tasks without hardcoding specific mechanisms. The library, provided as libpam, enables applications to delegate operations to configurable modules, supporting a modular approach to user verification across systems. The core API begins with pam_start(), which initializes a PAM transaction by creating a handle (pam_handle_t *) and associating it with a service name, username, and conversation structure for user interaction. This function returns PAM_SUCCESS (0) on successful initialization or an error code otherwise, preparing the context for subsequent operations. Following authentication or management steps, pam_end() cleans up the , releasing resources and terminating the transaction, with no return value but relying on the prior status for logging. For the authentication phase, [pam_authenticate()](/page/pam_authenticate) verifies the 's identity by prompting for credentials (e.g., ) and invoking the configured stack, accepting flags like PAM_SILENT to suppress diagnostic messages. It returns PAM_SUCCESS if the is authenticated or PAM_AUTH_ERR (7) on failure, such as invalid credentials. Post-, pam_acct_mgmt() performs validity checks, including expiration, restrictions, and resource limits, also returning PAM_SUCCESS or an appropriate . User interaction during these processes is managed through the conversation interface, defined by the struct pam_conv passed to pam_start(). This structure includes a (conv) to a callback that handles prompts and responses—such as echoing passwords or displaying messages—and an application data pointer (appdata_ptr) for custom context. For instance, modules may use this to request input via or dialogs, ensuring secure handling of sensitive data like passwords without direct application involvement. Error handling in the relies on return codes from each , with PAM_SUCCESS indicating no error and specific values like PAM_AUTH_ERR for failures. Applications can convert these codes to human-readable strings using pam_strerror(), which takes the PAM handle and error code as arguments to generate descriptive messages. Flags such as PAM_DISALLOW_NULL_AUTHTOK can be passed to functions like pam_authenticate() to enforce rejection of empty tokens, enhancing security. The library is thread-safe when each thread uses its own distinct PAM handle, avoiding shared state issues across concurrent authentications. A basic C program skeleton for authenticating a user against a PAM service, such as "login," demonstrates the typical flow; this example assumes a simple terminal-based conversation function (pam_tty_conv) for password input:
c
#include <security/pam_appl.h>
#include <stdio.h>
#include <pwd.h>

int main(int argc, char *argv[]) {
    pam_handle_t *pamh = NULL;
    struct pam_conv conv = { pam_tty_conv, NULL };  // Terminal conversation callback
    int retval;
    struct passwd *pw;

    if (argc < 2) {
        fprintf(stderr, "Usage: %s username\n", argv[0]);
        return 1;
    }

    pw = getpwnam(argv[1]);
    if (!pw) {
        fprintf(stderr, "User not found\n");
        return 1;
    }

    retval = pam_start("login", pw->pw_name, &conv, &pamh);
    if (retval == PAM_SUCCESS) {
        retval = pam_authenticate(pamh, 0);  // Authenticate with default flags
        if (retval == PAM_SUCCESS) {
            retval = pam_acct_mgmt(pamh, 0);  // Check account
        }
        if (retval == PAM_SUCCESS) {
            printf("Authentication successful\n");
        } else {
            fprintf(stderr, "Account management failed: %s\n", pam_strerror(pamh, retval));
        }
        pam_end(pamh, retval);
    } else {
        fprintf(stderr, "PAM start failed: %s\n", pam_strerror(NULL, retval));
    }

    return (retval == PAM_SUCCESS ? 0 : 1);
}
This skeleton initializes the context, authenticates the user, verifies the account, and cleans up, using pam_strerror() for error reporting.

Security Considerations

Common Vulnerabilities

One notable vulnerability in Linux PAM is CVE-2025-6018, a local privilege escalation flaw in the pam-config module. This issue arises from a misconfiguration that allows unprivileged local users (e.g., via SSH) to gain "allow_active" status, enabling access to polkit actions reserved for physically present console users and potentially leading to elevated privileges, including root access when chained with other flaws. Discovered in June 2025, it affects distributions such as openSUSE Leap 15 and SUSE Linux Enterprise 15, where default PAM configurations permit this unauthorized polkit access during authentication processes. When chained with CVE-2025-6019 in udisks (a flaw in libblockdev exploitable via the udisks daemon allowing full root escalation from "allow_active" status), it facilitates complete root access from standard user sessions. More recent issues in the pam_namespace module include CVE-2025-6020 (June 2025), where the module may use access to user-controlled paths without proper protection, allowing local , and CVE-2025-8941 (September 2025), a coupled with manipulation that enables local attackers to escalate to root privileges, both affecting Linux-PAM versions prior to patches. Credential harvesting attacks represent another significant threat to PAM, primarily exploiting the pam_conv in misconfigured or compromised modules to intercept passwords. Attackers often deploy PAM modules, such as modified versions of pam_unix.so, to log or exfiltrate credentials during flows for services like SSH or ; for instance, by editing the module's (e.g., pam_unix_auth.c) to append logging statements like "DFIR username=[%s] password=[%s]" and replacing the legitimate library. These attacks can leverage timing vulnerabilities akin to race conditions during module loading, capturing credentials before they reach secure processing. A 2025 Group-IB report highlights real-world examples, including threat actors UNC1945 and UNC2891, who inserted backdoor PAM modules on and systems to harvest credentials silently, often storing them in hidden log files or transmitting to external servers. Historical vulnerabilities in PAM modules have included issues like the symlink attack in pam_unix prior to version 1.2.1 (addressed in CVE-2015-3238), where the _unix_run_helper_binary function failed to sanitize paths, allowing local users to predict and manipulate temporary files for unauthorized access or escalation. Additionally, denial-of-service () risks have stemmed from modules like pam_faillock, where excessive failed login triggers could exhaust resources or indefinitely lock legitimate users if thresholds are not properly tuned, though no dedicated CVE exists for this configuration-dependent behavior; a related local was fixed in pam_namespace via CVE-2024-22365, preventing crashes from malformed inputs. These older flaws underscore persistent challenges in path validation and resource management within . In integrations, the pam_krb5 module's design to primarily fetch Ticket Granting Tickets (TGTs) for initial can lead to incomplete (SSO) implementations, requiring additional service tickets for full functionality and exposing risks if configurations omit proper ticket renewal or validation. This limitation may result in vulnerabilities if timestamps or session keys are not rigorously enforced, as Kerberos protections rely on synchronized clocks and usage, but misconfigurations in pam_krb5 can bypass these, allowing duplicated TGTs to be reused across sessions. Such pitfalls have been noted in documentation and analyses of PAM-Kerberos setups, emphasizing the need for comprehensive ticket management to mitigate unauthorized access. These vulnerabilities commonly enable local and unauthorized access to sensitive credentials, with impacts amplified in multi-user environments; affected systems can be mitigated through timely updates and auditing to enforce strict controls and .

Best Practices

Enforcing strong password policies is essential for PAM configurations to prevent weak credentials from compromising system . The pam_pwquality should be integrated into the password stack in files such as /etc/pam.d/system-auth or /etc/pam.d/password-auth, with options like retry=3 to limit attempts and enforce checks against words or common patterns. in /etc/security/pwquality.conf can specify rules such as a minimum length of 12 characters (minlen = 12), requirements for multiple character classes (minclass = 4), and avoidance of repetitive or sequential patterns (maxrepeat = 3, maxsequence = 3), aligning with organizational standards to reduce brute-force risks. Password rotation can be managed through the pam_unix module, which interacts with shadow password fields to enforce aging policies defined in /etc/login.defs, such as a maximum age of 90 days (PASS_MAX_DAYS 90) and a minimum of 7 days between changes (PASS_MIN_DAYS 7), prompting users to update expired credentials during . This approach ensures periodic renewal without allowing immediate reuse of recent passwords via pam_pwhistory integration, typically set to remember the last 5 passwords (remember=5). Implementing multi-factor authentication (MFA) enhances PAM by stacking modules like pam_unix for primary credentials with pam_google_authenticator for time-based one-time passwords (TOTP) on critical services such as SSH. Install the module via package managers (e.g., apt install libpam-google-authenticator on Debian-based systems), generate user-specific secrets with the google-authenticator command enabling rate-limiting and disallowing multiple uses, then add auth required pam_google_authenticator.so to /etc/pam.d/sshd and enable ChallengeResponseAuthentication yes in /etc/ssh/sshd_config. This setup requires both password and app-generated codes, significantly raising the bar against unauthorized access. Account lockout mechanisms protect against repeated failed login attempts, configurable via the pam_faillock in the auth and stacks of /etc/pam.d/system-auth. Typical settings include auth required pam_faillock.so preauth silent deny=5 unlock_time=900 to lock after 5 failures for (900 seconds), with account required pam_faillock.so to enforce the lock; include even_deny_root for protection and use the faillock to or reset counters (e.g., faillock --user <username> --reset). For , integrate PAM with the Linux system using pam_tty_audit in session stacks (e.g., session optional pam_tty_audit.so enable for specified users) to log TTY input to /var/log/audit/audit.log, enabling detection of suspicious activity without performance overhead. Minimizing privileges in PAM involves selecting strict control flags like required or requisite for sensitive modules, avoiding optional which permits failures without halting the , to ensure comprehensive verification. Centralize configurations by using include directives (e.g., @include common-auth in files) to reference shared files like /etc/pam.d/system-auth, promoting consistency and reducing misconfiguration risks across services. Regular maintenance of PAM setups requires periodic audits of /etc/pam.d/ directories to identify and remove unused or deprecated module references, preventing bloat and potential attack surfaces from outdated components. Test configurations non-interactively with the pamtester utility (e.g., pamtester -v <service> <user> authenticate), which simulates authentication phases to validate stack behavior without risking live systems. Additionally, on SELinux-enabled distributions, restrict PAM module execution paths using targeted policies (e.g., via semanage fcontext to label /lib64/security/ as pam_t and enforce with restorecon), confining modules to prevent unauthorized access or .

Recent Developments

Version History

The development of Linux PAM began with its initial integration into Red Hat Linux 3.0.4 in August 1996, marking the first widespread adoption of pluggable authentication modules in a major Linux distribution. Early versions, such as 0.68 released in July 1999, focused on basic module support and integration with system authentication services. By version 0.99 around 2006, significant improvements included enhanced support for glibc integration, enabling better compatibility with the GNU C Library for authentication tasks. Version 1.0.0, released in February 2006, represented a major milestone by stabilizing the and introducing a more robust framework for module development and . This release also marked a licensing shift from a pure BSD-style license to a dual GPL/BSD license, allowing greater flexibility for integration with both GPL-licensed and while maintaining open-source principles. Subsequent updates in the 1.x series built on this foundation; for instance, version 1.2.0 in 2015 added options like quiet logging in pam_unix and alternative support. Key releases continued to emphasize and . Version 1.5.0, released in , enhanced credential handling by removing deprecated modules like pam_tally and pam_tally2, promoting pam_faillock for account lockout management, adding new APIs such as pam_modutil_check_user_in_passwd for improved user validation, recommending pam_pwquality from the libpwquality library instead of the removed pam_cracklib module, and including fixes in pam_unix. In version 1.6.0 from January 2024, enhancements were introduced, including support for longer configuration lines and fixes for denial-of-service issues in pam_namespace (addressing CVE-2024-22365). Version 1.7.0, released in October 2024, addressed namespace-related fixes and switched the build system to for better portability, while adding constant-time password hashing in pam_unix to mitigate s. The most recent update, version 1.7.1 on June 17, 2025, primarily delivered security patches, including fixes for CVE-2024-10963 in pam_access and CVE-2025-6020 in pam_namespace, alongside minor improvements like rttime support in pam_limits and elogind integration. As of November 2025, version 1.7.1 remains the latest stable release. Regarding deprecations, the legacy /etc/pam.conf file serves only as a fallback if /etc/pam.d/ does not exist and has been deprecated since early versions; additionally, pam_lastlog was deprecated in 1.5.3 due to Y2038 compatibility issues. These changes reflect ongoing efforts to modernize the framework while preserving where feasible.

Modern Integrations

Linux PAM integrates seamlessly with through the pam_systemd module, which registers user sessions with the login manager (systemd-logind.service) upon login and logout. This integration enables session tracking, management of user seats, and integration with the control group hierarchy, allowing for efficient and monitoring of user activities across the system. By notifying logind of session events, pam_systemd supports features like automatic suspension of idle sessions and coordination with display managers for multi-user environments. For systems, PAM enhances through modules like pam_selinux for SELinux and pam_apparmor for . The pam_selinux module automatically maps Linux users to SELinux users during , setting the appropriate context to enforce confined and prevent unauthorized escalations. This ensures that user processes inherit the correct SELinux labels, supporting policy-based isolation in enterprise environments. Similarly, the pam_apparmor module (part of libpam-apparmor) applies AppArmor profiles on a per-user basis during , confining executables and processes to predefined profiles for fine-grained protection against exploits. In containerized environments, PAM configurations are typically shared via bind mounts of the host's /etc/pam.d directory into or Podman containers, enabling consistent without duplicating setups. The pam_namespace further supports by managing polyinstantiated directories and namespaces during session setup, such as mounting private instances for users to prevent cross-container interference and enhance security in multi-tenant setups. This approach is particularly useful in and deployments running container workloads, where pam_namespace handles unmounting and remounting options to align with container lifecycle events. Distributions like Amazon Linux leverage for local in EC2 instances, where roles are assumed via instance metadata services to grant temporary credentials, often integrated through PAM-aware services like SSSD for broader AWS SSO compatibility. In 24.04 LTS and later, PAM interfaces with Netplan for network scenarios, such as 802.1x/WPA Enterprise setups, where Netplan's configuration triggers PAM modules during supplicant-based logins to validate credentials against remote identity providers. Support for hardware authenticators is available via third-party modules like pam_u2f, which enables FIDO2 and U2F protocols for two-factor authentication in PAM stacks. This module allows seamless integration of YubiKeys and compatible devices into login processes, enhancing phishing resistance without altering core PAM flows.

References

  1. [1]
    PAM(8) - Linux manual page - man7.org
    This manual is intended to offer a quick introduction to Linux-PAM. For more information the reader is directed to the Linux-PAM system administrators' guide.
  2. [2]
    An introduction to Pluggable Authentication Modules (PAM) in Linux
    Jul 22, 2020 · PAM is about authentication. In most cases, when you log in to a system via a console or from across the network with SSH or Cockpit, PAM is involved.
  3. [3]
    Pluggable Authentication Modules for Linux | Linux Journal
    ### Summary of Linux-PAM History, Origins, Key Developments, and Notable Facts
  4. [4]
    Linux-PAM-1.7.1 - Linux From Scratch!
    Linux-PAM-1.7.1. Introduction to Linux PAM. The Linux PAM package contains Pluggable Authentication Modules used by the local system administrator to control ...
  5. [5]
    PAM(8) - Linux manual page - man7.org
    Linux-PAM is a system of libraries that handle the authentication tasks of applications (services) on the system.
  6. [6]
    Pluggable authentication modules (UNIX or Linux) - IBM
    A Pluggable Authentication Module (PAM) is a well-defined framework for supporting different authentication modules that were originally developed by Sun ...
  7. [7]
    RFC NNN - The Open Group
    In this RFC we discuss the architecture and design of pluggable authentication modules. This design gives the capability to use field-replaceable ...Missing: OSF- | Show results with:OSF-
  8. [8]
    History of Red Hat Linux - Fedora Project Wiki
    This document describes that history, particularly focusing on the development themes for each release of Linux provided by Red Hat.
  9. [9]
    Pluggable Authentication Modules - XSSO Sign-on Services
    Previous section. X/Open Single Sign-on Service (XSSO) - Pluggable ... PAM (Pluggable Authentication Modules) provides system administrators with the flexibility ...
  10. [10]
  11. [11]
    Anatomy of a Linux Pluggable Authentication Modules (PAM ...
    Jul 29, 2020 · In this article, we will walk through the configuration files for a local sudo command. When using sudo, we switch users and do something.Missing: 3.0.4 August 1996
  12. [12]
    PAM(8) - Arch manual pages
    Linux-PAM separates the tasks of authentication into four independent management groups: account management; authentication management; password management; and ...
  13. [13]
    pam.d(5): PAM config files - Linux man page
    These files list the PAMs that will do the authentication tasks required by this service, and the appropriate behavior of the PAM-API in the event that ...
  14. [14]
    10.2. About PAM Configuration Files | Red Hat Enterprise Linux | 7
    Each PAM configuration file contains a group of directives that define the module (the authentication configuration area) and any controls or arguments with it.
  15. [15]
    2 Authentication with PAM - SUSE Documentation
    PAM modules are processed as stacks. Different types of modules have different purposes. For example, one module checks the password, another verifies the ...
  16. [16]
    How PAM Stacking Works
    The maximum number for the PAM include stack is 32. Optional – Success in meeting an optional module's requirements is not necessary for using the service.Missing: mechanism | Show results with:mechanism
  17. [17]
    PAM authentication modules - Rocky Linux Documentation
    Usually authenticates with a password by comparing it to a value stored in a database, or by relying on an authentication server,. Establishes account settings: ...Introduction · Mechanisms · Control Indicators · PAM modules<|control11|><|separator|>
  18. [18]
    16.2. PAM Configuration Files - Red Hat Documentation
    In earlier versions of PAM, the file /etc/pam.conf was used, but this file is now deprecated and is only used if the /etc/pam.d/ directory does not exist.
  19. [19]
    LDAP/PAM - Debian Wiki
    Apr 14, 2025 · The /etc/pam.d/common-* files are managed by pam-auth-update (from libpam-runtime). The libpam-ldapd package ...
  20. [20]
    Chapter 4. Authentication and access controls - Debian
    You change the PAM configuration files in the " /etc/pam.d/ " directory to use " pam_ldap.so " instead of the default " pam_unix.so ". Debian uses " /etc ...
  21. [21]
    pam(3) - Linux manual page - man7.org
    DESCRIPTION top. PAM is a system of libraries that handle the authentication tasks of applications (services) on the system. The library provides a stable ...<|control11|><|separator|>
  22. [22]
    pam_unix(8) - Linux man page
    The default action of this module is to not permit the user access to a service if their official password is blank. The nullok argument overrides this default.
  23. [23]
    pam_unix(8) - Linux manual page - man7.org
    This is the standard Unix authentication module. It uses standard calls from the system's libraries to retrieve and set account information as well as ...
  24. [24]
    pam_tally2(8) - Linux manual page - man7.org
    Aug 27, 2021 · pam_tally2 is an (optional) application which can be used to interrogate and manipulate the counter file. It can display user counts, set ...
  25. [25]
    pam_faillock(8) - Linux manual page - man7.org
    The setup of pam_faillock in the PAM stack is different from the pam_tally2 module setup. Individual files with the failure records are created as owned by ...
  26. [26]
    pam_env(8) - Linux manual page - man7.org
    The pam_env PAM module allows the (un)setting of environment variables. Supported is the use of previously set environment variables as well as PAM_ITEMs such ...
  27. [27]
    pam_limits(8) - Linux manual page - man7.org
    The pam_limits PAM module sets limits on the system resources that can be obtained in a user-session. Users of uid=0 are affected by this limits, too. By ...
  28. [28]
    pam_deny(8) - Linux manual page - man7.org
    This module can be used to deny access. It always indicates a failure to the application through the PAM framework.
  29. [29]
    pam_permit(8) - Linux manual page - man7.org
    pam_permit is a PAM module that always permit access. It does nothing else. In the case of authentication, the user's name will be set to nobody if the ...Missing: pam_deny | Show results with:pam_deny
  30. [30]
    Linux PAM (Pluggable Authentication Modules for Linux) project
    The script is targeted at Debian based Linux distributions so the package names and availability might differ on other distributions.Linux-pam · Issues 123 · Pull requests 34 · ActionsMissing: built- | Show results with:built-<|control11|><|separator|>
  31. [31]
    pam_ldap - LDAP pluggable authentication module - Ubuntu Manpage
    The pam_ldap module is a Pluggable Authentication Module (PAM) which provides for authentication, authorization and password changing against LDAP servers.
  32. [32]
    13.2.6. Configuring Services: PAM - Red Hat Documentation
    SSSD provides a PAM module, sssd_pam, which instructs the system to use SSSD to retrieve user information. The PAM configuration must include a reference to ...
  33. [33]
    pam_krb5 - Kerberos PAM module - Ubuntu Manpage
    The Kerberos service module for PAM, typically installed at /lib/security/pam_krb5.so, provides functionality for the four PAM operations: authentication, ...
  34. [34]
    48.6.4. Kerberos and PAM - Red Hat Documentation
    The pam_krb5 package contains sample configuration files that allow services such as login and gdm to authenticate users as well as obtain initial credentials ...
  35. [35]
    google/google-authenticator-libpam - GitHub
    Google Authenticator PAM module. Example PAM module demonstrating two-factor authentication for logging into servers via SSH, OpenVPN, etc… This project is ...
  36. [36]
    PAM module for Google two-factor authentication - Ubuntu Manpage
    The pam_google_authenticator module is designed to protect user authentication with a second factor, ei‐ ther time-based (TOTP) or counter-based (HOTP). Prior ...Missing: Linux | Show results with:Linux
  37. [37]
    Setting up multi-factor authentication on Linux systems - Red Hat
    Aug 11, 2020 · In this article, we use the Google PAM module to enable MFA so users can log in by using time-based one-time password (TOTP) codes.
  38. [38]
    How to configure pam_radius on RHEL - Red Hat Customer Portal
    Aug 15, 2024 · How can I configure pam_radius for authentication on Red Hat Enterprise Linux (RHEL); How can I configure pam_radius for sudo authentication?Missing: module | Show results with:module
  39. [39]
    FreeRADIUS/pam_radius - GitHub
    This is the PAM to RADIUS authentication module. It allows any Linux, OSX or Solaris machine to become a RADIUS client for authentication and password change ...
  40. [40]
    pam.conf(5) - Linux manual page - man7.org
    When a PAM aware privilege granting application is started, it activates its attachment to the PAM-API. This activation performs a number of tasks, the most ...
  41. [41]
    pam_tty_audit(8) - Linux manual page - man7.org
    The pam_tty_audit module enables or disables TTY auditing for specified users. By default, the kernel does not audit input on any TTY.
  42. [42]
    Sudoers Manual | Sudo
    On systems that use PAM for authentication, sudo will attempt to establish credentials for the target user by default, if supported by the underlying ...
  43. [43]
    pam_authenticate(3) - Linux manual page - man7.org
    The pam_authenticate function is used to authenticate the user. The user is required to provide an authentication token depending upon the authentication ...
  44. [44]
    pam(3) - Linux man page - Die.net
    The pam_authenticate(3) function is used to authenticate the user. The user is required to provide an authentication token depending upon the authentication ...
  45. [45]
    The Linux-PAM Application Developers' Guide - chiark
    This manual documents what an application developer needs to know about the Linux-PAM library. It describes how an application might use the Linux-PAM library ...
  46. [46]
  47. [47]
  48. [48]
  49. [49]
    A Simple PAM Consumer Example - Oracle Help Center
    The application calls pam_authenticate(3PAM) to authenticate the current user. ... pam_start("plock", pw->pw_name, &conv, &pamh); if (err != PAM_SUCCESS) ...
  50. [50]
    CVE-2025-6018 Detail - NVD
    Jul 23, 2025 · A Local Privilege Escalation (LPE) vulnerability has been discovered in pam-config within Linux Pluggable Authentication Modules (PAM). This ...
  51. [51]
    Qualys TRU Uncovers Chained LPE: SUSE 15 PAM to Full Root via ...
    Jun 18, 2025 · Chaining CVE-2025-6018 and CVE-2025-6019 lets any SUSE 15/Leap 15 SSH user leap from “normal” to root with the default PAM + udisks installed.<|separator|>
  52. [52]
    New Linux Flaws Enable Full Root Access via PAM and Udisks ...
    Jun 19, 2025 · The cybersecurity company said CVE-2025-6018 is present in the PAM configuration of openSUSE Leap 15 and SUSE Linux Enterprise 15, enabling ...
  53. [53]
    Understanding Credential Harvesting via PAM: A Real-World Threat
    May 8, 2025 · Learn how attackers exploit Pluggable Authentication Modules (PAM) for credential harvesting—and discover defenses to harden Linux ...
  54. [54]
    Releases · linux-pam/linux-pam - GitHub
    Oct 24, 2024 · Linux-PAM 1.7.1. Jun 17 · v1.7.1 ; Linux-PAM 1.7.0. Oct 24, 2024 · v1.7.0 ; Linux-PAM 1.6.1. Apr 9, 2024 · v1.6.1 ; Linux-PAM 1.6.0. Jan 17, 2024 · v1.
  55. [55]
    CVE-2025-6018 Common Vulnerabilities and Exposures - SUSE
    A Local Privilege Escalation (LPE) vulnerability has been discovered in pam-config within Linux Pluggable Authentication Modules (PAM). This flaw allows an ...
  56. [56]
    Chapter 4. Hardening Your System with Tools and Services | 7
    In Red Hat Enterprise Linux 7, the pam_faillock PAM module allows system administrators to lock out user accounts after a specified number of failed attempts.
  57. [57]
    Security Guide | Red Hat Enterprise Linux | 7
    ... pam_pwquality module is used to check a password's strength against a set of rules. Its procedure consists of two steps: first it checks if the provided ...
  58. [58]
    Configure SSH to use two-factor authentication - Ubuntu
    To make SSH use the Google Authenticator PAM module, add the following line to the /etc/pam.d/sshd file: auth required pam_google_authenticator.so. Now you ...
  59. [59]
    7.9. Configuring PAM for Auditing - Red Hat Documentation
    The audit system in Red Hat Enterprise Linux uses the pam_tty_audit PAM module to enable or disable auditing of TTY input for specified users.Missing: sudo | Show results with:sudo
  60. [60]
    Configuring authentication and authorization in RHEL
    Linux-PAM (Pluggable Authentication Modules) is a system of modules that handle the authentication tasks of applications (services) on the system. The nature ...Missing: pam_ldap | Show results with:pam_ldap<|separator|>
  61. [61]
    pamtester - test pluggable authentication modules (PAM) facility
    pamtester is a tiny utility program to test the pluggable authentication modules (PAM) facility, which is a de facto standard of unified authentication ...
  62. [62]
    SELinux User's and Administrator's Guide | Red Hat Enterprise Linux
    This book consists of two parts: SELinux and Managing Confined Services. The former describes the basics and principles upon which SELinux functions.
  63. [63]
    Pluggable Authentication Module - Wikipedia
    A pluggable authentication module (PAM) is a mechanism to integrate multiple low-level authentication schemes into a high-level application programming ...
  64. [64]
  65. [65]
    Index of /pub/linux/libs/pam/pre/library/ - The Linux Kernel Archives
    ... Linux-PAM-0.68.tar.gz.asc 05-Jul-1999 06:26 285 Linux-PAM-0.68.tar.sign 08-Aug-2013 19:43 665 Linux-PAM-0.69.tar.gz 02-Aug-1999 04:02 376K Linux-PAM-0.69 ...
  66. [66]
    Ftp2 - /pub/blfs/conglomeration/Linux-PAM - Open Source Lab
    Linux-PAM-0.99.4.0-docs.tar.bz2, 2006-05-13 02:41, 857K. [ ], Linux-PAM-0.99.4.0 ... Linux-PAM-1.0.3-docs.tar.bz2, 2008-12-09 08:41, 697K. [ ], Linux-PAM-1.0.3 ...Missing: history early releases 0.68<|control11|><|separator|>
  67. [67]
    None
    ### Summary of License Text
  68. [68]
    libpwquality/libpwquality: Password quality checking library - GitHub
    The libpwquality library purpose is to provide common functions for password quality checking and also scoring them based on their apparent randomness.
  69. [69]
    pam_systemd - Freedesktop.org
    pam_systemd registers user sessions with the systemd login manager systemd-logind.service(8), and hence the systemd control group hierarchy.Missing: integration | Show results with:integration
  70. [70]
    pam_systemd - Register user sessions in the systemd login manager
    pam_systemd registers user sessions with the systemd login manager systemd-logind.service(8), and hence the systemd control group hierarchy.
  71. [71]
    systemd-logind.service - Freedesktop.org
    systemd-logind is a system service that manages user logins. It is responsible for: User sessions are registered with logind via the pam_systemd(8) PAM module.Missing: integration | Show results with:integration
  72. [72]
    Using SELinux | Red Hat Enterprise Linux | 8
    Log in as the Linux <example_user> user. When you log in, the pam_selinux PAM module automatically maps the Linux user to an SELinux user (in this case ...
  73. [73]
    Managing AppArmor profiles - ADSys documentation
    Aug 11, 2025 · Installing the AppArmor PAM module¶. The PAM module can be installed on Ubuntu using the following command: sudo apt install libpam-apparmor.
  74. [74]
    Considerations in adopting RHEL 8 | Red Hat Enterprise Linux
    The oscap-podman tool provides an equivalent of the oscap-docker utility that serves for scanning container and container images in RHEL 7. For more ...
  75. [75]
    Chapter 11. Configuring polyinstantiated directories | Using SELinux
    Add the session required pam_namespace.so unmnt_remnt entry into the module for each service for which polyinstantiation should apply, after the session include ...
  76. [76]
    Chapter 5. RHEL 8.2.0 release | Red Hat Enterprise Linux | 8
    The pam_faillock module, a part of pluggable authentication modules (PAM), can now read settings from the configuration file located at /etc/security/faillock.
  77. [77]
    Manually joining an Amazon EC2 Linux instance to your AWS ...
    Learn how to manually join a Amazon EC2 Linux instance to your AWS Managed Microsoft AD Active Directory after the instance was launched.
  78. [78]
    BionicBeaver/ReleaseNotes/ChangeSummary/18.04.3 - Ubuntu Wiki
    Aug 8, 2019 · Added support for WPA Enterprise / 802.1x authentication. netplan.io ... Backport netplan.io 0.97 to 18.04. netplan.io. 1763608. networkd ...Desktop Fixes · Server And Cloud Related... · Kernel And Hardware Support...Missing: integration | Show results with:integration<|separator|>
  79. [79]
    pam-u2f - Yubico Developers
    This module implements PAM over U2F and FIDO2, providing an easy way to integrate the YubiKey (or other U2F/FIDO2 compliant authenticators) into your existing ...Service Configuration · Module Arguments · Authorization Mapping FilesMissing: post- | Show results with:post-