In Red Hat Enterprise Linux 7, the pam_pwquality PAM module replaced pam_cracklib, which was used in Red Hat Enterprise Linux 6 as a default module for password quality checking. It uses the same back end as pam_cracklib.
The code was originally based on pam_cracklib module, and the module is backwards compatible with its options.
The pam_pwquality module can be customized and configured in the file /etc/security/pwquality.conf.
The possible options in the file are:
difok
Number of characters in the new password that must not be present in the old password. (default 5)minlen
Minimum acceptable size for the new password (plus one if credits are not disabled which is the default). (See pam_pwquality(8).) Cannot be
set to lower value than 6. (default 9)dcredit
The maximum credit for having digits in the new password. If less than 0 it is the minimum number of digits in the new password. (default 1)ucredit
The maximum credit for having uppercase characters in the new password. If less than 0 it is the minimum number of uppercase characters in
the new password. (default 1)lcredit
The maximum credit for having lowercase characters in the new password. If less than 0 it is the minimum number of lowercase characters in
the new password. (default 1)ocredit
The maximum credit for having other characters in the new password. If less than 0 it is the minimum number of other characters in the new
password. (default 1)minclass
The minimum number of required classes of characters for the new password (digits, uppercase, lowercase, others). (default 0)maxrepeat
The maximum number of allowed same consecutive characters in the new password. The check is disabled if the value is 0. (default 0)maxsequence
The maximum length of monotonic character sequences in the new password. Examples of such 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. The check is disabled if the
value is 0. (default 0)maxclassrepeat
The maximum number of allowed consecutive characters of the same class in the new password. The check is disabled if the value is 0.
(default 0)gecoscheck
If nonzero, check whether the words longer than 3 characters from the GECOS field of the user’s passwd entry are contained in the new pass‐
word. The check is disabled if the value is 0. (default 0)badwords
Space separated list of words that must not be contained in the password. These are additional words to the cracklib dictionary check. This
setting can be also used by applications to emulate the gecos check for user accounts that are not created yet.dictpath
Path to the cracklib dictionaries. Default is to use the cracklib default.SEE ALSO
pwscore(1), pwmake(1), pam_pwquality(8)
PAM, pam – Pluggable Authentication Modules for Linux
The password policy in RHEL 7, and most other linux distributions, is handled by the PAM (Pluggable Authentication Modules) system. The dynamically-configurable system can be modified in /etc/pam.conf and /etc/pam.d/.
Linux-PAM separates the tasks of authentication into four independent management groups: account management; authentication management; password management; and session management. (We highlight the abbreviations used for
these groups in the configuration file.)Simply put, these groups take care of different aspects of a typical user’s request for a restricted service:
account – provide account verification types of service: has the user’s password expired?; is this user permitted access to the requested service?
authentication – authenticate a user and set up user credentials. Typically this is via some challenge-response request that the user must satisfy: if you are who you claim to be please enter your password. Not all
authentications are of this type, there exist hardware based authentication schemes (such as the use of smart-cards and biometric devices), with suitable modules, these may be substituted seamlessly for more standard
approaches to authentication – such is the flexibility of Linux-PAM.password – this group’s responsibility is the task of updating authentication mechanisms. Typically, such services are strongly coupled to those of the auth group. Some authentication mechanisms lend themselves well to being
updated with such a function. Standard UN*X password-based access is the obvious example: please enter a replacement password.session – this group of tasks cover things that should be done prior to a service being given and after it is withdrawn. Such tasks include the maintenance of audit trails and the mounting of the user’s home directory. The
session management group is important as it provides both an opening and closing hook for modules to affect the services available to a user.
cat /etc/pam.d/system-auth #%PAM-1.0 # This file is auto-generated. # User changes will be destroyed the next time authconfig is run. auth required pam_env.so auth sufficient pam_fprintd.so auth sufficient pam_unix.so nullok try_first_pass auth requisite pam_succeed_if.so uid >= 1000 quiet_success auth required pam_deny.so account required pam_unix.so account sufficient pam_localuser.so account sufficient pam_succeed_if.so uid < 1000 quiet account required pam_permit.so password requisite pam_pwquality.so try_first_pass local_users_only retry=3 authtok_type= password sufficient pam_unix.so sha512 shadow nullok try_first_pass use_authtok password required pam_deny.so session optional pam_keyinit.so revoke session required pam_limits.so -session optional pam_systemd.so session [success=1 default=ignore] pam_succeed_if.so service in crond quiet use_uid session required pam_unix.so
There are a number of different options that are placed in the /etc/pam.d/system-auth file that allows system administrators to further customize the implementation of the various modules in PAM. The following options are available for the pam_pwquality module:
debug
This option makes the module write information to syslog(3) indicating the behavior of the module (this option does not write password informa‐
tion to the log file).authtok_type=XXX
The default action is for the module to use the following prompts when requesting passwords: “New UNIX password: ” and “Retype UNIX password: “.
The example word UNIX can be replaced with this option, by default it is empty.retry=N
Prompt user at most N times before returning with error. The default is 1.difok=N
This argument will change the default of 5 for the number of changes in the new password from the old password.minlen=N
The minimum acceptable size for the new password (plus one if credits are not disabled which is the default). In addition to the number of char‐
acters in the new password, credit (of +1 in length) is given for each different kind of character (other, upper, lower and digit). The default
for this parameter is 9 . Note that there is a pair of length limits also in Cracklib, which is used for dictionary checking, a “way too short”
limit of 4 which is hard coded in and a build time defined limit (6) that will be checked without reference to minlen.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 +1 towards
meeting the current minlen value. The default for dcredit is 1 which is the recommended value for minlen less than 10.(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 letter
will count +1 towards meeting the current minlen value. The default for ucredit is 1 which is the recommended value for minlen less than 10.(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 let‐
ter will count +1 towards meeting the current minlen value. The default for lcredit is 1 which is the recommended value for minlen less than 10.(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 character
will count +1 towards meeting the current minlen value. The default for ocredit is 1 which is the recommended value for minlen less than 10.(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 default number is zero. The four classes are digits, upper and
lower letters and other characters. The difference to the credit check is that a specific class if of characters is not required. Instead N out
of four of the classes are required.maxrepeat=N
Reject passwords which contain more than N same consecutive characters. The default is 0 which means that this check is disabled.maxsequence=N
Reject passwords which contain monotonic character sequences longer than N. The default is 0 which means that this check is disabled. Examples
of such 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 which contain more than N consecutive characters of the same class. The default is 0 which means that this check is disabled.gecoscheck=N
If nonzero, check whether the individual words longer than 3 characters from the passwd GECOS field of the user are contained in the new pass‐
word . The default is 0 which means that this check is disabled.badwords=’list of words’
The words more than 3 characters long from this space separated list are individually searched for and forbidden in the new password. By
default the list is empty which means that this check is disabled.enforce_for_root
The module will return error on 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/passwd file. The module still asks for the password so
the following modules in the stack can use the use_authtok option. 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 use the one provided by the previously stacked password
module.dictpath=/path/to/dict
Path to the cracklib dictionaries.
An additional configuration file worth mentioning within the context of password policy is the /etc/login.defs file; it’s provided by the setup package. The /etc/login.defs file defines the site-specific configuration for the shadow password suite. Though, it’s not part of the PAM system, this file is required; absence of it will not
prevent system operation, but will probably result in undesirable operation.