Configuring User Authentication and Password Policies
If you follow traditional digital identity policies, the Pluggable Authentication Modules (PAM) feature can be used to enforce strong user authentication and password policies, including rules that decide password complexity, length, age, expiration, and the reuse of previous passwords. You can configure PAM to block user access after too many failed login attempts, after normal working hours, or if too many concurrent sessions are open. Note that some of these policies are no longer considered helpful for security as they can lead users to implement their own poor security practices when storing passwords or when renewing. See https://pages.nist.gov/800-63-3/sp800-63-3.html for more information.
pam_pwquality.so
tests password strength. The PAM configuration file (/etc/pam.d/system-auth
)
contains the following default entries for testing a password's strength:
password requisite pam_pwquality.so local_users_only retry=3 authtok_type= enforce_for_root password requisite pam_pwhistory.so use_authtok enforce_for_root remember=4 password sufficient pam_unix.so sha512 shadow use_authtok enforce_for_root remember=4 password sufficient pam_sss.so use_authtok password required pam_deny.so
The line for pam_pwquality.so
defines that a user gets three tries to
choose a good password. From the module's default settings, the password length must a minimum
of six characters, of which three characters can't be the same as a previous password. The
module only tests the quality of passwords for users who are defined in the
/etc/passwd
file.
The line for pam_unix.so
specifies that the module tests the old password
that was specified in the stack before prompting for a new password and uses the SHA-512
password hashing and the /etc/shadow
file to decide access. Note that
pam_pwquality
will have performed such checks for users that have been
defined in the /etc/passwd
file.
You can configure the control flags and module parameters to change the checks that are performed when a user changes their password:
password required pam_pwquality.so retry=3 minlen=8 difok=5 minclass=-1 password required pam_unix.so use_authtok sha512 shadow remember=5 password required pam_deny.so
The line for pam_pwquality.so
specifies that a user is allowed three tries
to choose a good password, with a minimum of eight characters, of which five characters must
be different from the previous password, and which must contain at least one uppercase letter,
one lowercase letter, one numeric digit, and one special character.
The line for pam_unix.so
specifies that the module doesn't perform password
checking, uses SHA-512 password hashing and the /etc/shadow
file, and saves
information about the previous five passwords for each user in the
/etc/security/opasswd
file.
For more information, see the pam_deny(8)
,
pam_pwquality(8)
, and
pam_unix(8)
manual pages.