Set Existing Passwords Minimum Age

Classification:

compliance

Framework:

Control:

Description

Configure non-compliant accounts to enforce a 24 hours/1 day minimum password lifetime by running the following command:

$ sudo chage -m 1 USER

Rationale

Enforcing a minimum password lifetime helps to prevent repeated password changes to defeat the password reuse or history enforcement requirement. If users are allowed to immediately and continually change their password, the password could be repeatedly changed in a short period of time to defeat the organization’s policy regarding password reuse.

Remediation

Shell script

The following script can be run on the host to remediate the issue.

var\_accounts\_minimum\_age\_login\_defs='1'


while IFS= read -r i; do
 
 chage -m $var\_accounts\_minimum\_age\_login\_defs $i

done < <(awk -v var="$var\_accounts\_minimum\_age\_login\_defs" -F: '(/^[^:]+:[^!\*]/ && ($4 < var || $4 == "")) {print $1}' /etc/shadow)