Information
A cryptographic hash function converts an arbitrary-length input into a fixed length output. Password hashing performs a one-way transformation of a password, turning the password into another string, called the hashed password.
Weak or legacy password hashing algorithms such as md5 and DES are fast to compute, so an attacker who obtains the stored password hashes can crack them offline at high speed. A strong algorithm (yescrypt or SHA-512) is deliberately expensive to compute, greatly increasing the effort required to recover local user passwords from the stored hashes.
Solution
The pam_unix arguments are configured through the active authselect profile so that the change is durable; editing /etc/pam.d/system-auth or /etc/pam.d/password-auth directly is not durable, because authselect regenerates those files (see the section overview for the authselect profile model).
Set yescrypt, the default and recommended algorithm on this platform:
-
Ensure the system is using a custom authselect profile. If it is still on a stock profile, create and select one first, as described in the section overview.
-
On the pam_unix.so line in the password stack of the active custom profile templates ( /etc/authselect/custom/<profile>/system-auth and /etc/authselect/custom/<profile>/password-auth ), ensure the hashing algorithm is set to yescrypt and remove any other algorithm such as md5, sha256, bigcrypt, or blowfish. A compliant line reads:
password sufficient pam_unix.so yescrypt shadow use_authtok
- Apply the change so that /etc/pam.d/system-auth and /etc/pam.d/password-auth are regenerated with the strong hashing algorithm:
# authselect apply-changes
Note: The hashing algorithm applies to passwords set after the change; existing password hashes remain in place until each account's password is next changed.
Systems with a FIPS 140 requirement:
yescrypt is not a FIPS-approved algorithm and must not be used where FIPS compliance is mandated. Use sha512 instead, which is also a strong algorithm, by specifying sha512 in place of yescrypt in step 2 and then applying the change. Such environments additionally enable system-wide FIPS mode, which aligns the system crypto policy with the FIPS-approved algorithm:
# fips-mode-setup --enable