Stack Engineer

Setup Password Expiration on CentOS

It's always a good security practice to enable password expiration on your system. If anyone comprises your password, it should only be good for a limited amount of time. On CentOS 7, this can be accomplished with the chage tool.

Step 1 - Install Chage

If you don't have it already installed, you can install it with the following command.

sudo yum install chage

Step 2 - Check Password Expiration Date

You can view the date the password expires for a particular user by using the following command. Be sure to replace username with the actual username.

chage -l username

Step 3 - Set Password Expiration

To set the maxinum number of days between the system forcing a password change, the following command can be used. Be sure to replace days with the number of days between password changes and username with the actual username.

chage -M days username

Remove Password Expiration

To disable password aging, you can set the maximum number of days between forcing a user to change their password with teh following command. Be sure to replace username with the actual username.

chage -M 99999 username