37.2.4. Password Aging
chagecommand with an option from Table 37.3, “
chageCommand Line Options”, followed by the username.
chagecommand. For more information, see Section 37.6, “Shadow Passwords”.
chage Command Line Options
| ||Specifies the minimum number of days between which the user must change passwords. If the value is 0, the password does not expire.|
| || Specifies the maximum number of days for which the password is valid. When the number of days specified by this option plus the number of days specified with the |
| ||Specifies the number of days since January 1, 1970 the password was changed|
| ||Specifies the number of inactive days after the password expiration before locking the account. If the value is 0, the account is not locked after the password expires.|
| ||Specifies the date on which the account is locked, in the format YYYY-MM-DD. Instead of the date, the number of days since January 1, 1970 can also be used.|
| ||Specifies the number of days before the password expiration date to warn the user.|
| ||Lists current account aging settings.|
chagecommand is followed directly by a username (with no options), it displays the current password aging values and allows them to be changed interactively.
- Set up an initial password — There are two common approaches to this step. The administrator can assign a default password or assign a null password.To assign a default password, use the following steps:
Alternatively, you can assign a null password instead of an initial password. To do this, use the following command:
- Start the command line Python interpreter with the
pythoncommand. It displays the following:
Python 2.4.3 (#1, Jul 21 2006, 08:46:09) [GCC 4.1.1 20060718 (Red Hat 4.1.1-9)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>>
- At the prompt, type the following commands. Replace <password> with the password to encrypt and <salt> with a random combination of at least 2 of the following: any alphanumeric character, the slash (/) character or a dot (.):
print crypt.crypt("<password>","<salt>")The output is the encrypted password, similar to
- Press Ctrl-D to exit the Python interpreter.
- At the shell, enter the following command (replacing <encrypted-password> with the encrypted output of the Python interpreter):
usermod -p "<encrypted-password>" <username>
usermod -p "" username
WarningUsing a null password, while convenient, is a highly unsecure practice, as any third party can log in first an access the system using the unsecure username. Always make sure that the user is ready to log in before unlocking an account with a null password.
- Force immediate password expiration — Type the following command:
chage -d 0 usernameThis command sets the value for the date the password was last changed to the epoch (January 1, 1970). This value forces immediate password expiration no matter what password aging policy, if any, is in place.