How to configure a user account to never expire on CentOS/RHEL
In some situations, you may want to configure a user account to never expire its password. This can be helpful in cases where a user needs to use the same password for a long period of time, such as for service accounts or accounts used by automated processes. Here's how to configure a user account to never expire on CentOS/RHEL.
Prerequisites
Before we begin, you need to have a user account set up on your CentOS/RHEL system.
Step 1: Verify Password Expiration
First, let's verify if password expiration is set for the user account. Run the following command to view the password expiration information for the user:
sudo chage -l [username]
Replace [username] with the username of the account that you want to check.
The output will show the account's password expiration information, including the maximum number of days the password is valid.
Step 2: Set Password Expiration to Never
To set the password expiration to never, run the following command:
sudo chage -m 0 -M -1 -I -1 -E -1 [username]
Replace [username] with the username of the account that you want to configure.
The options in the command are:
- -m 0: Set the minimum number of days between password changes to 0.
- -M -1: Set the maximum number of days between password changes to -1 (i.e., never).
- -I -1: Set the "inactive" password expiration to never.
- -E -1: Set the account expiration to never.
This will configure the user account to never expire its password.
Step 3: Verify the Changes
To verify that the changes have been applied, run the following command:
sudo chage -l [username]
The output should show that the password expiration has been set to "never".
Conclusion
In this tutorial, we have shown how to configure a user account to never expire its password on CentOS/RHEL. By setting the maximum number of days between password changes to -1, we can ensure that the password will never expire, making it more convenient for service accounts and automated processes that require long-term use of a fixed password.
I hope you found this tutorial helpful. If you have any questions or feedback, please feel free to leave a comment below. Happy coding!