Linux - Force User To Change Password

It's useful to be able to force users to change their passwords the next time they log in. To do so, simply enter the following command:

sudo chage -d 0 [user-name]
For example
sudo chage -d 0 programster
The change command is for changing the user password expiry information with -d 0 specifying the number of days since January 1st, 1970 when the password was last changed.

Set Password To Expire in X days

If want to password to expire in x days instead (and force the user to change the password every x days afterwards) simply run the following command:

sudo chage -M [number of days] [username]
e.g.
sudo chage -M 30 programster

Disabling Password Expirey

If people complain about having to change their passwords, one can disable this feature with the following command

sudo chage -m 0 -M 99999 -I -1 -E -1 [username]
  • -m 0 will set the minimum number of days between password change to 0
  • -M 99999 will set the maximum number of days between password change to 99999
  • -I -1 (number minus one) will set the “Password inactive” to never
  • -E -1 (number minus one) will set “Account expires” to never.

References

No comments:

Post a Comment