Information
If the pwquality enforce_for_root option is enabled, 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: The root is not asked for an old password so the checks that compare the old and new password are not performed.
More information about the pam_pwquality.so module configuration files, their location, and load preference is available in the section overview.
Use of a complex password helps to increase the time and resources required to compromise the password. Password complexity, or strength, is a measure of the effectiveness of a password in resisting attempts at guessing and brute-force attacks.
Password complexity is one factor of several that determines how long it takes to crack a password. The more complex the password, the greater the number of possible combinations that need to be tested before the password is compromised.
Solution
Create or modify a file ending in .conf in the /etc/security/pwquality.conf.d/ directory and add or modify the following line to set the enforce_for_root option:
enforce_for_root
Example:
#!/usr/bin/env bash
{
[ ! -d /etc/security/pwquality.conf.d/ ] && mkdir /etc/security/pwquality.conf.d/
printf '\n%s\n' "enforce_for_root" > /etc/security/pwquality.conf.d/50-pwroot.conf
}