Use it when logins fail unexpectedly, to add MFA or lockout, or to enforce password quality.
PAM
PAM (Pluggable Authentication Modules) is the stack of modules (/etc/pam.d/<service>) that services such as login, sshd and sudo use for authentication, account checks, sessions and password changes.
1. Which service file? /etc/pam.d/sshd, sudo, common-auth/system-auth.
2. Read the auth log: journalctl -u sshd / /var/log/secure.
3. Lockout? faillock --user <user>.
4. Change via authselect / pam-auth-update.
5. Test from a second session before logging out.
service calls PAM → auth modules → account checks → session setup → result
For Security → PAM, continue with the first unproven Topic check: Record exact host, distribution/kernel, boot ID, time window, workload, identity and the authoritative configuration/policy source for PAM. If that boundary is healthy, advance to the adjacent check: Read back the effective runtime state and precedence rather than assuming an edited file, package state or service status is active. Preserve the same host/time/identity scope and rerun the original workload before accepting recovery.
Continue only after interpreting the current observation.Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Operational evidence path Verify boundary
PAM-aware service → service stack/includes → module order/control flags → authentication → account → session/password phase → application decision → audit/workload
Healthy evidence: the intended service resolves the expected stack, module control flow is understood, allowed/denied test identities behave correctly and logs correlate the decision
Step 2 Verification and output interpretation Verify boundary
Verification chain. PAM-aware service → service stack/includes → module order/control flags → authentication → account → session/password phase → application decision → audit/workload
Step 3 Commands Verify boundary
ls /etc/pam.d
grep -r pam_faillock /etc/pam.d
authselect current # RHEL
Step 4 Failure modes and next checks Narrow the fault
Suspicious evidence: wrong service file/include is used, control flags bypass required checks, account/session phase differs from auth, module errors fail unexpectedly, or application behavior disagrees with PAM result
Step 5 Common mistakes Narrow the fault
- Editing PAM files by hand on systems managed by authselect.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
Module order and control flags (required, requisite, sufficient) decide the result. On RHEL edit via authselect, on Debian via pam-auth-update — not by hand. Always keep a root session open when changing PAM.
faillock --user <user>— failed-login lockout statesestatus / aa-status— SELinux or AppArmor statess -tulpn— listening servicesjournalctl -u sshd -g 'Failed'— failed loginsausearch -m avc,user_login -ts today— audit events (auditd)
ReferenceWhat it is1 section · depth on demand
Scope and canonical references
This is the canonical Linux PAM Topic (Pluggable Authentication Modules): stacks, module types, control flags and authselect.
- Hardening the PAM stack (lockout, password quality, MFA modules): PAM under Security → Linux Security.
- Not the same as Privileged Access Management, which is also abbreviated PAM: see Privileged Access Management under Identity.
ReferenceImportant terms & boundaries5 sections · depth on demand
What this shows and what it does not
PAM is confirmed only for the exact participating service and phase under test, but it does not show non-PAM authentication paths or application authorization beyond the returned PAM result.
In depth
PAM: how Linux authentication is assembled
PAM (Pluggable Authentication Modules) lets each program that authenticates users, such as login, sshd, sudo or su, use a configurable stack of modules. The pam.conf(5) manual page describes the configuration:
- Each service has a file in
/etc/pam.d/, named after the service. - Each line has a type, a control value, a module path and arguments.
- The four types are
auth(verify identity),account(allowed now?),password(change credentials) andsession(set up and tear down the session). - Lines of the same type are evaluated in order.
Control values (manual)
| Control | Effect |
|---|---|
required | Must succeed, but the remaining modules still run, and failure is reported at the end |
requisite | Must succeed; failure returns immediately |
sufficient | Success ends the stack (if nothing required failed before); failure is ignored |
optional | Matters only if it's the only module of that type |
include / substack | Pull in lines from another file |
[success=1 default=ignore] | The bracket syntax, for exact control (used heavily by Debian) |
A - before the type, for example -session, keeps PAM from logging an error if the module isn't installed.
Common modules
| Module | Purpose |
|---|---|
pam_unix | Local passwords from /etc/shadow |
pam_sss | SSSD (AD and LDAP users) |
pam_faillock | Lock accounts after failed attempts (RHEL family) |
pam_pwquality | Password strength rules |
pam_limits | Resource limits from /etc/security/limits.conf |
pam_access | Allow or deny logins by user and origin (/etc/security/access.conf) |
pam_google_authenticator / pam_u2f | Second factor |
pam_mkhomedir | Create home directories at first login |
Changing PAM safely
| Practice | Reason |
|---|---|
Use the distribution's tools: authselect (RHEL), pam-auth-update (Debian) | They keep the stacks consistent |
| Keep a root shell open while testing | A broken stack can lock everyone out |
| Test each service: ssh, sudo, console | They use different files |
host$ cat /etc/pam.d/sshd | grep -vE '^\s*(#|$)'
@include common-auth
account required pam_nologin.so
@include common-account
session required pam_limits.so
@include common-session
host$ grep -vE '^\s*(#|$)' /etc/pam.d/common-auth
auth [success=2 default=ignore] pam_unix.so nullok
auth [success=1 default=ignore] pam_sss.so use_first_pass
auth requisite pam_deny.so
auth required pam_permit.so
host$ sudo authselect current
host$ sudo faillock --user alice
host$ sudo journalctl -t sshd -g "pam_" --since today | tail -3
Reading common-auth
[success=2 default=ignore] means: if pam_unix succeeds, skip the next two lines and land on pam_permit. If it fails, try pam_sss, which on success skips one line. If both fail, pam_deny ends the stack with an error. That's how Debian expresses "local password or directory password".
Documented example, not captured output.
How it works at runtime
PAM is part of Security → PAM. PAM is the Linux authentication/account/session/password stack used by PAM-aware services, where module order, control flags, includes and application integration determine the effective decision.
Runtime state ownership and mechanics. Linux security composes authentication (PAM and service mechanisms), identity/credentials, DAC permissions/ACLs, capabilities, LSM policy such as SELinux/AppArmor, audit and service/network policy.
Topic-specific state model. PAM is the Linux authentication/account/session/password stack used by PAM-aware services, where module order, control flags, includes and application integration determine the effective decision.
Technical metadata. Linux distribution/kernel + boot/time + user/group/process/service identity + PAM/SSH/DAC/ACL + SELinux/AppArmor mode/context/profile + audit/log correlation + key/certificate/SAN/EKU/chain/trust store/SNI + original workload result.
Interpretation rule. - A PAM configuration file exists ≠ the target service uses that stack.
- One module returns success ≠ the whole auth/account/session flow succeeds or is authorized.
Quick reference
PAM (Pluggable Authentication Modules) chains modules per service in /etc/pam.d/<service> across four types: auth, account, password, session. Control flags decide the outcome:
| Flag | Meaning |
|---|---|
required | Must succeed; continue, fail at end |
requisite | Must succeed; fail immediately |
sufficient | Success ends the stack (if nothing required failed) |
optional | Only matters if it is the only module |
include / substack | Pull in another file |
# lockout after 5 failures (RHEL 8+/Debian 12)
auth required pam_faillock.so preauth deny=5 unlock_time=900
faillock --user alice; faillock --user alice --reset
On RHEL use authselect to manage PAM profiles rather than editing files by hand; always keep a root shell open while testing PAM changes.
Limits and how it fails
Primary failure point. PAM is confirmed only for the exact participating service and phase under test, but it does not show non-PAM authentication paths or application authorization beyond the returned PAM result.
PAM success does not show sudo, filesystem or application authorization. Security controls should remain explicit layers rather than a single “permission denied” bucket.
ReferenceConfiguration & state1 section · depth on demand
Configuration, persistence and lifecycle
PAM stack order/control flags matter; sudo/SSH hardening can lock out administration; SELinux policy should normally be fixed through correct labels/booleans/policy rather than permanent disablement; AppArmor profiles should move from complain to enforce only after reviewing legitimate workload behavior.
Distribution/platform context. PAM owns stack evaluation; SSH, sudo, login/display managers and applications own their integration and post-auth authorization.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Security → PAM. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://docs.kernel.org/security/index.html · confidence 94%What changed and what may be affected
Recent technical edits are separated from ordinary page timestamps. Relationship impact is advisory: it identifies nearby canonical references to review, not automatic breakage.
Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.
Quick lookup tables
PAM operational reference
Topic-specific lookup boundaries, proof limits and next-step Evidence for PAM.
| Lookup boundary | Topic-specific reference | Operational use |
|---|---|---|
| Scope / effective state | PAM is the Linux authentication/account/session/password stack used by PAM-aware services, where module order, control flags, includes and application integration determine the effective decision. | Establish exactly what this Topic owns before crossing into another subsystem. |
| Fast verification | Pin host + boot/time + real identity/workload → identify authoritative policy/key/trust source → read back loaded/effective runtime state → reproduce one safe allow/deny/handshake test → correlate audit/service/kernel evidence → locate first failed boundary → make the smallest persistent change → repeat original workload + regression/recovery check. | Use the shortest evidence path first; a fast check is a boundary test, not blanket proof. |
| Verification chain | PAM-aware service → service stack/includes → module order/control flags → authentication → account → session/password phase → application decision → audit/workload | Trace requested/configured state through effective state to the observed workload result. |
| Failure boundary | PAM is proven only for the exact participating service and phase under test; it does not prove non-PAM authentication paths or application authorization beyond the returned PAM result. | Stop broad troubleshooting at the first boundary that is not supported by evidence. |
| Positive evidence | Correlated Linux security/trust evidence can establish this proof path: PAM-aware service → service stack/includes → module order/control flags → authentication → account → session/password phase → application decision → audit/workload | Use this observation only for the specific claim it actually supports. |
| Evidence limit | It does not independently prove unobserved identities, objects, policies, namespaces, endpoints or time periods. PAM is proven only for the exact participating service and phase under test; it does not prove non-PAM authentication paths or application authorization beyond the returned PAM result. | Do not promote a local success signal into end-to-end or adjacent-dependency proof. |
| Next troubleshooting check | Continue from the first unproven security/trust boundary, capture the adjacent effective state and audit/handshake evidence, make only the demonstrated persistent change, then repeat the original workload plus recovery/regression checks. | Continue to the next unresolved boundary while preserving the original test condition. |
PAM · operational reference
Compact Linux state, persistence, verification and boundary reference for fast lookup.
| Reference boundary | PAM |
|---|---|
| Topic path | Security → PAM |
| Runtime state | PAM is the Linux authentication/account/session/password stack used by PAM-aware services, where module order, control flags, includes and application integration determine the effective decision. |
| Fast checks | - Record exact host, distribution/kernel, boot ID, time window, workload, identity and the authoritative configuration/policy source for PAM. - Read back the effective runtime state and precedence rather than assuming an edited file, package state or service status is active. - Reproduce one safe allowed/denied or handshake/access test and correlate kernel/service/audit evidence at the first relevant boundary. - Apply the smallest persistent cause-specific change, then repeat the original test plus an adjacent regression/recovery check. |
| Verification chain | PAM-aware service → service stack/includes → module order/control flags → authentication → account → session/password phase → application decision → audit/workload Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return/regression → explicit Evidence boundary. Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return path or regression → explicit Evidence boundary. |
| Failure boundary | PAM is proven only for the exact participating service and phase under test; it does not prove non-PAM authentication paths or application authorization beyond the returned PAM result. Boundary chain: process/context → userspace configuration → kernel subsystem/resource → device/network/filesystem dependency → effective state → original workload. |
| Persistence rule | Prove which configuration source owns the state, then prove that the running consumer loaded or generated the intended state. |