Saucepan

How to guides and technology tutorials for Amazon AWS, Google Cloud, Linux, macOS, Windows, and other systems

How to setup password expiration on CentOS

Published: 05 February 2017
Updated: 29 April 2020
Filed Under: 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.

Install Chage

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

sudo yum install chage

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

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 the following command. Be sure to replace username with the actual username.

chage -M 99999 username