Stack Engineer

Setup Automatic Account Expiration on CentOS

If you need to grant access to a specific user but only for a few days, you can set their account to expire automatically after a specific date with the chage tool.

Set Account Expiration Date

To set their account to expire, run the following command. Be sure to replace YYYY-MM-DD with the correct year, month, and day to expire on and username with the actual username.

chage -E "YYYY-MM-DD" username

Remove Account Expiration

To disable the account from automatically expiring, you can run the following command. Be sure to replace username with the actual username.

chage -E -1 username