PAM_PWQUALITY(8)
๐ PAM_PWQUALITY โ the pam_pwquality manual, bestie edition ๐
okay so we're doing PAM_PWQUALITY(8) from the Linux-PAM Manual today, and honestly? this one's a baddie. it's the module that looks at your password and goes "girl... no." โจ
โจ NAME โจ
pam_pwquality โ a PAM module that does password quality checking ๐
๐ธ SYNOPSIS ๐ธ
pam_pwquality.so [...]
๐ฆ DESCRIPTION ๐ฆ
So here's the vibe: you can plug this module into the password stack of any service, and it'll do some plug-in strength-checking on passwords for you. The code was originally based on the pam_cracklib module, and it's backwards compatible with all of that module's options. iconic behavior, honestly. ๐
What this module actually does is prompt the user for a password and then check how strong it is against a system dictionary plus a whole set of rules for spotting bad choices. it's giving personal trainer but for your password.
The first move is to prompt for a single password, check its strength, and then โ only if it's considered strong โ prompt for the password a second time, to verify you typed it right the first time. If all goes well, the password gets passed along to the subsequent modules so it can be installed as the new authentication token. slay.
Here are the checks it runs:
- Palindrome โ is the new password a palindrome? ๐
- Case Change Only โ is the new password literally the same as the old one, just with the case changed?
- Similar โ is the new password too much like the old one? This one is primarily controlled by a single argument,
difok, which is the number of character changes (inserts, removals, or replacements) between the old and new password that are enough to accept the new password. - Simple โ is the new password too small? This is controlled by 6 arguments:
minlen,maxclassrepeat,dcredit,ucredit,lcredit, andocredit. Head to the arguments section for the deets on how these work and what their defaults are. - Rotated โ is the new password a rotated version of the old password?
- Same consecutive characters โ optional check for same consecutive characters.
- Too long monotonic character sequence โ optional check for too long monotonic character sequence.
- Contains user name โ checks whether the password contains the user's name in some form.
- Dictionary check โ the Cracklib routine gets called to check if the password is part of a dictionary. ๐
All of these checks are configurable either by using the module arguments or by editing the /etc/security/pwquality.conf configuration file. And important: the module arguments override the settings in the configuration file. periodt.
๐ OPTIONS ๐
debugโ makes the module write information tosyslog(3)about what it's doing. (and no, this option does not write password information to the log file. privacy queen. ๐)authtok_type=XXXโ the default action is for the module to use these prompts when requesting passwords:"New UNIX password: "and"Retype UNIX password: ". The example wordUNIXcan be replaced with this option โ by default it's empty.retry=Nโ prompt the user at most N times before returning with an error. The default is1.difok=Nโ this argument changes the default of1for the number of changes in the new password from the old password.- The special value of
0disables all checks of similarity of the new password with the old password โ except for the new password being exactly the same as the old one. ๐ฌ
- The special value of
minlen=Nโ the minimum acceptable size for the new password (plus one if credits are not disabled, which is the default). On top of the number of characters in the new password, you get credit (of+1in length) for each different kind of character (other, upper, lower and digit). The default for this parameter is8. Note that there's also a pair of length limits in Cracklib, which is used for dictionary checking: a "way too short" limit of4which is hard coded in, and a build time defined limit (6) that will be checked without reference tominlen.dcredit=N- (
N >= 0) this is the maximum credit for having digits in the new password. If you have less than or N digits, each digit will count+1towards meeting the currentminlenvalue. The default fordcreditis0, which means there's no bonus for digits in the password. - (
N < 0) this is the minimum number of digits that must be met for a new password.
- (
ucredit=N- (
N >= 0) this is the maximum credit for having upper case letters in the new password. If you have less than or N upper case letters, each upper case letter will count+1towards meeting the currentminlenvalue. The default forucreditis0, which means there's no bonus for upper case letters in the password. - (
N < 0) this is the minimum number of upper case letters that must be met for a new password.
- (
lcredit=N- (
N >= 0) this is the maximum credit for having lower case letters in the new password. If you have less than or N lower case letters, each lower case letter will count+1towards meeting the currentminlenvalue. The default forlcreditis0, which means there's no bonus for lower case letters in the password. - (
N < 0) this is the minimum number of lower case letters that must be met for a new password.
- (
ocredit=N- (
N >= 0) this is the maximum credit for having other characters in the new password. If you have less than or N other characters, each other character will count+1towards meeting the currentminlenvalue. The default forocreditis0, which means there's no bonus for other characters in the password. - (
N < 0) this is the minimum number of other characters that must be met for a new password.
- (
minclass=Nโ the minimum number of required classes of characters for the new password. The four classes are digits, upper and lower letters, and other characters. The difference from the credit check is that a specific class of characters is not required โ instead, N out of the four classes are required. By default the check is disabled.maxrepeat=Nโ reject passwords that contain more than N same consecutive characters. The default is0, which means this check is disabled.maxsequence=Nโ reject passwords that contain monotonic character sequences longer than N. The default is0, which means this check is disabled. Examples of such a sequence are'12345'or'fedcb'. Note that most such passwords will not pass the simplicity check unless the sequence is only a minor part of the password.maxclassrepeat=Nโ reject passwords that contain more than N consecutive characters of the same class. The default is0, which means this check is disabled.gecoscheck=Nโ if nonzero, check whether the individual words longer than3characters from thepasswd(5)GECOS field of the user are contained in the new password. The default is0, which means this check is disabled.dictcheck=Nโ if nonzero, check whether the password (with possible modifications) matches a word in a dictionary. Currently the dictionary check is performed using the cracklib library. The default is1, which means this check is enabled. โusercheck=Nโ if nonzero, check whether the password (with possible modifications) contains the user name in some form. The default is1, which means this check is enabled. It is not performed for user names shorter than3characters.usersubstr=Nโ if greater than3(due to the minimum length inusercheck), check whether the password contains a substring of the user name of at least N length in some form. The default is0, which means this check is disabled.enforcing=Nโ if nonzero, reject the password if it fails the checks; otherwise it only prints the warning. The default is1, which means the weak password is rejected (for non-root users).badwords=<list of words>โ the words more than3characters long from this space separated list are individually searched for and forbidden in the new password. By default the list is empty, which means this check is disabled. ๐ซdictpath=/path/to/dictโ this option allows you to specify a non-default path to the cracklib dictionaries.enforce_for_rootโ the module will return an error on a failed check even if the user changing the password is root. This option is off by default, which means that just the message about the failed check is printed, but root can change the password anyway. Note that root is not asked for an old password, so the checks that compare the old and new password are not performed. ๐local_users_onlyโ the module will not test the password quality for users that are not present in the/etc/passwdfile. The module still asks for the password so the following modules in the stack can use theuse_authtokoption. This option is off by default.use_authtokโ this argument is used to force the module to not prompt the user for a new password, but instead use the one provided by the previously stacked password module.
๐ MODULE TYPES PROVIDED ๐
Only the password module type is provided. that's it, that's the whole list. ๐
โญ RETURN VALUES โญ
PAM_SUCCESSโ the new password passes all checks. yay!! ๐PAM_AUTHTOK_ERRโ no new password was entered, the username could not be determined, or the new password fails the strength checks.PAM_AUTHTOK_RECOVERY_ERRโ the old password was not supplied by a previous stacked module, or it got not requested from the user. The first error can happen ifuse_authtokis specified.PAM_SERVICE_ERRโ an internal error occurred. ๐
okay wait, there's still more of this page coming โ don't go anywhere bestie, part 2 is right behind this ๐ซถ
๐ซ EXAMPLES ๐ซ
okay bestie, real talk, this is the part where it all comes together โจ lemme show you how this module gets stacked with the password component of pam_unix(8).
First one up โ and listen, this is the classic:
#
# These lines stack two password type modules. In this example the
# user is given 3 opportunities to enter a strong password. The
# "use_authtok" argument ensures that the pam_unix module does not
# prompt for a password, but instead uses the one provided by
# pam_pwquality.
#
password required pam_pwquality.so retry=3
password required pam_unix.so use_authtok
so basically you got two password type modules stacked like the iconic duo they are, and the user gets 3 chances to come up with a strong password. and the use_authtok argument? that's the MVP ๐ซถ it makes sure the pam_unix module does NOT prompt for a password โ it just takes the one pam_pwquality already got. no double-prompting, no chaos, no drama ๐
next scenario: you want that sha256 password encryption, bestie, so let's go ๐
#
# These lines allow modern systems to support passwords of at least 14
# bytes with extra credit of 2 for digits and 2 for others the new
# password must have at least three bytes that are not present in the
# old password
#
password required pam_pwquality.so \
difok=3 minlen=15 dcredit=2 ocredit=2
password required pam_unix.so use_authtok nullok sha256
okay so what's happening here: modern systems get to support passwords of at least 14 bytes ๐ฆ, plus extra credit of 2 for digits and 2 for others, and the new password has to have at least three bytes that are not present in the old password (difok=3). it's giving โจthoroughโจ ngl.
and last one, the "we're not doing credits today" edition ๐
#
# These lines require the user to select a password with a minimum
# length of 8 and with at least 1 digit number, 1 upper case letter,
# and 1 other character
#
password required pam_pwquality.so \
dcredit=-1 ucredit=-1 ocredit=-1 lcredit=0 minlen=8
password required pam_unix.so use_authtok nullok sha256
here the user has to pick a password with a minimum length of 8, plus at least 1 digit number, 1 upper case letter, and 1 other character. note how the credits are negative (dcredit=-1 ucredit=-1 ocredit=-1) โ that's the "you must have at least this many" mode, while lcredit=0 is just chilling ๐ periodt.
๐ฆ SEE ALSO ๐ฆ
go read those too, they're the supporting cast and honestly? they ate ๐
๐ AUTHORS ๐
- Tomas Mraz
<tmraz@redhat.com> - Original author of the
pam_cracklibmodule, Cristian Gafton<gafton@redhat.com>
and that's a wrap bestie!! ๐ธ this whole page comes to you from Red Hat, Inc., dated 2022-11-18, and it's PAM_PWQUALITY(8) โ the password quality icon it was always meant to be ๐
โจ no cap, go forth and set your minlen responsibly ๐ซถ๐
๐ฆ where this page comes from
- alpine 3.24: libpwquality-doc 1.4.5-r6 ยท BSD-3-Clause
- debian bookworm: libpam-pwquality 1.4.5-1+b1 ยท libpwquality OR GPL-2.0-or-later
- debian trixie: libpam-pwquality 1.4.5-5 ยท libpwquality OR GPL-2.0-or-later
- fedora 43: libpwquality 1.4.5-14.fc43 ยท BSD-3-Clause OR GPL-2.0-or-later
- fedora 43: libpwquality 1.4.5-14.fc43 ยท BSD-3-Clause OR GPL-2.0-or-later
- fedora 44: libpwquality 1.4.5-15.fc44 ยท BSD-3-Clause OR GPL-2.0-or-later
- fedora 44: libpwquality 1.4.5-15.fc44 ยท BSD-3-Clause OR GPL-2.0-or-later
- opensuse-leap 16.0: pam_pwquality 1.4.5-160000.3.2 ยท BSD-3-Clause OR GPL-2.0-or-later
- opensuse-leap 16.0: pam_pwquality 1.4.5-160000.3.2 ยท BSD-3-Clause OR GPL-2.0-or-later
- opensuse-leap 16.0: pam_pwquality 1.4.5-160000.3.2 ยท BSD-3-Clause OR GPL-2.0-or-later
- opensuse-leap 16.0: pam_pwquality 1.4.5-160000.3.2 ยท BSD-3-Clause OR GPL-2.0-or-later
- ubuntu noble: libpam-pwquality 1.4.5-3build1 ยท libpwquality OR GPL-2.0-or-later
- ubuntu questing: libpam-pwquality 1.4.5-5
- ubuntu resolute: libpam-pwquality 1.4.5-5build1 ยท libpwquality OR GPL-2.0-or-later
- ubuntu stonking: libpam-pwquality 1.4.5-5build1 ยท libpwquality OR GPL-2.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms