Local password changes can fail a quality check before the system saves the new password. On Ubuntu 26.04 LTS, the PAM stack for passwd shows which password quality rules apply to local accounts.
PAM services select their own password stacks. For a local change with passwd, the service file usually pulls in a shared stack that lists the modules in the order PAM calls them.
The rules for someone choosing their own password can differ from the rules for an administrator resetting it. A failed quality check can produce a warning during a root-run reset while blocking the same choice for an ordinary user.
Steps to check PAM password quality rules in Linux:
- Read the active entries in
/etc/pam.d/passwdfrom a regular user shell.$ grep -E '^[[:space:]]*[^#[:space:]]' /etc/pam.d/passwd @include common-password
@include common-passwordpoints to/etc/pam.d/common-password. The file reads require no password input. - Locate the quality module in the included
/etc/pam.d/common-passwordstack.$ grep -E '^[[:space:]]*[^#[:space:]]' /etc/pam.d/common-password password requisite pam_pwquality.so retry=3 minlen=16 ##### snipped #####
The
requisitecontrol stops the change if the quality module returns an error.If the fully traced stack has no dedicated quality module, the audit ends there.
pam_unix.socan still apply basic checks withobscure.The configuration reads apply when the
passwdpassword stack reachespam_pwquality.sothrough the shown include, so stop if it uses a different quality module, has untraced password entries, or cannot be read, because the audit is incomplete. - List the drop-ins in
/etc/security/pwquality.conf.d/in filename order.$ LC_ALL=C ls -1A /etc/security/pwquality.conf.d/ 20-base.conf 50-local.conf
LC_ALL=Cmatches the module's ASCII filename order. If two drop-ins set the same option, the file later in that order wins. If the directory is missing or has no.conffiles, skip the drop-in read. A permission error leaves the audit incomplete. - Read the uncommented settings in the listed
.confdrop-ins, substituting their quoted paths in the same order.$ grep -HE '^[[:space:]]*[^#[:space:]]' \ '/etc/security/pwquality.conf.d/20-base.conf' \ '/etc/security/pwquality.conf.d/50-local.conf' /etc/security/pwquality.conf.d/20-base.conf:dcredit = -2 /etc/security/pwquality.conf.d/50-local.conf:minlen = 12 /etc/security/pwquality.conf.d/50-local.conf:dcredit = -1A read error leaves the audit incomplete.
dcredit,ucredit,lcredit, andocreditapply to digits, uppercase letters, lowercase letters, and other characters. A positive value caps the bonus towardminlen. A negative value requires that many characters of the class.minclasssets the minimum number of classes. - Read the uncommented settings in the main
/etc/security/pwquality.conffile.$ grep -E '^[[:space:]]*[^#[:space:]]' /etc/security/pwquality.conf minlen = 14
- Resolve each effective setting from the PAM arguments, main file, and drop-ins.
The module applies the drop-ins first, the main file next, and the PAM arguments last. In the output above,
minlen=16from PAM anddcredit=-1from50-local.confgive a length check of at least 16 bytes and a requirement for at least one digit. A UTF-8 character can count as multiple bytes.A readable main file with no uncommented settings adds no overrides. Settings absent from all three layers keep their defaults, including
minlen=8and zero credits. If the main file is unreadable, stop because the audit is incomplete.An effective
enforcing=0makes failures warnings. With enforcement enabled,enforce_for_rootalso makes failures block root-run resets.