Article Title: Linux User Management: Set the User Password validity period. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Password aging is an enhanced system Password authentication mechanism. Although it may weaken the user's convenience, it ensures regular Password replacement, this is a very good security measure. Most Linux releases do not enable the password aging Function by default, but we can easily enable it.
1. Edit the/etc/login. defs file. You can use the following parameters to modify the default password aging Configuration:
# Password aging controls:
# PASS_MAX_DAYS the password validity period is set to 9999. In fact, the password aging function is disabled.
# PASS_MIN_DAYS indicates the number of days since the last password change before the user is allowed to change the password
# PASS_MIN_LEN
# PASS_WARN_AGE indicates how many days before the password expires to notify the user that the password is about to expire
PASS_MAX_DAYS 9999
PASS_MIN_DAYS 0
PASS_WARN_AGE 7
2. You can also edit the/etc/default/useradd file to find the INACTIVE and EXPIRE keywords:
# Useradd defaults file
GROUP = 100
HOME =/home
INACTIVE = 14
// When the password has expired and the user has not changed the password, the user's account will be locked as unavailable. The above settings are 14 days,
EXPIRE =
// Specifies the expiration date of the new user's password, in the format of YYYY-MM-DD.
SHELL =/bin/bash
The preceding settings are only valid for new users created after Configuration modification. To change the user configuration that has been created, you can use the chage tool:
[Root @ rhel4 ~] # Chage-M 60 shangwen
Set PASS_MAX_DAYS of shangwen to 60 days and update the shadow file accordingly. We can use the-l option to view information about password aging,-m to set PASS_MIN_DAYS,-W to set PASS_WARN_AGE, and so on. The chage tool allows us to set parameters for password aging. The following are detailed chage parameters:
Usage: chage [Option] User Name
Option:
-D, -- lastday: Set the last password to "last date"
-E, -- expiredate: Set the Account expiration time to "expiration date"
-H, -- help: displays the help information and exits.
-I, -- inactive: Set the password that expires due to expiration to "invalid password"
-L, -- list displays account age information
-M, -- mindays: set the minimum number of days between two password changes to "minimum number of days"
-M, -- maxdays the maximum number of days between two password changes is set to "Maximum number of days"
-W, -- warndays warning days set the days of expiration warning to "Warning days"