4.4.2.1.2 Ensure password failed attempts lockout is configured

Information

The deny=<n> option will deny access if the number of consecutive authentication failures for this user during the recent interval exceeds

.

Locking out user IDs after

n

unsuccessful consecutive login attempts mitigates brute force password attacks against your systems.

Solution

Edit the files /etc/pam.d/system-auth and /etc/pam.d/password-auth :

Add the following lines to the auth section:

auth required pam_faillock.so preauth silent audit deny=5 unlock_time=900 even_deny_root
auth [default=die] pam_faillock.so authfail audit deny=5 unlock_time=900 even_deny_root

The auth sections should look similar to the following example:

Example:

auth required pam_env.so
auth required pam_faillock.so preauth silent audit deny=5 unlock_time=900 even_deny_root # <- Under "auth required pam_env.so"
auth sufficient pam_unix.so try_first_pass
auth [default=die] pam_faillock.so authfail audit deny=5 unlock_time=900 even_deny_root # <- Last auth line before "auth requisite pam_succeed_if.so"
auth requisite pam_succeed_if.so uid >= 1000 quiet_success
auth required pam_deny.so

WARNING: The ordering on the lines in the auth section is important. The preauth line needs to below the line auth required pam_env.so and above all password validation lines. The authfail line needs to be after all password validation lines such as pam_sss.so Incorrect order can cause you to be locked out of the system.

See Also

https://workbench.cisecurity.org/benchmarks/15964