How to configure password expiry in Linux
We can configure the password expiration interval in the configuration file "/etc/login.defs".
PASS_MAX_DAYS 120 PASS_MIN_DAYS 0 PASS_WARN_AGE 8
The value of above parameters need to updated with the required values.
Please note that this will be applicable only for new users. In-order to apply password expiration policy to existing users, chage command can be used.
To configure the maximum number of days after which a user should change the password,
chage -M DAYS USERNAME
To configure the minimum number of days required between the change of password,
chage -m DAYS USERNAME
To configure warning prior to password expiration,
chage -W DAYS USERNAME
Where DAYS and USERNAME need to be replaced with the appropriate values.