Information
The /etc/security/opasswd file stores the users' old passwords and can be checked to ensure that users are not recycling recent passwords.
remember=<5> - Number of old passwords to remember
Rationale:
Forcing users not to reuse their past 5 passwords make it less likely that an attacker will be able to guess the password.
Note that these change only apply to accounts configured on the local system.
Solution
Set remembered password history to conform to site policy. Run the folloing script to add or modify the pam_pwhistory.so and pam_unix.so lines to include the remember option:
CP=$(authselect current | awk 'NR == 1 {print $3}' | grep custom/) [[ -n $CP ]] && PTF=/etc/authselect/$CP/system-auth || PTF=/etc/authselect/system-auth [[ -n $(grep -E '^s*passwords+(sufficients+pam_unix|requi(red|site)s+pam_pwhistory).sos+([^#]+s+)*remember=S+s*.*$' $PTF) ]] && sed -ri 's/^s*(passwords+(requisite|sufficient)s+(pam_pwquality.so|pam_unix.so)s+)(.*)(remember=S+s*)(.*)$/14 remember=5 6/' $PTF || sed -ri 's/^s*(passwords+(requisite|sufficient)s+(pam_pwquality.so|pam_unix.so)s+)(.*)$/14 remember=5/' $PTF authselect apply-changes
Notes:
Additional module options may be set, recommendation only covers those listed here.