centos8安全策略操作系统用户密码有效期修改和关闭
1. 使用 chage 命令可以查看当前用户的密码过期信息:
chage -l ci
Last password change : Feb 01, 2025
Password expires : May 02, 2025
Password inactive : never
Account expires : never
Minimum number of days between password change : 0
Maximum number of days between password change : 90
Number of days of warning before password expires : 7
2. 通过以下方法修改密码过期时间:
sudo chage -M 99999 ci
-
-M 99999:将密码有效期设置为 99999 天(几乎相当于永不过期)。 -
ci:目标用户名。
完全关闭密码过期功能,可以将 -M 设置为 -1:
sudo chage -M -1 ci
3. 修改系统默认的密码策略
编辑 /etc/login.defs 文件:
PASS_MAX_DAYS 99999 # 密码最大有效期
PASS_MIN_DAYS 0 # 密码最小修改间隔
PASS_WARN_AGE 7 # 密码过期前警告天数
4. 修改 PAM 配置
完全禁用密码过期检查,可以修改 PAM 配置。编辑 /etc/pam.d/system-auth 文件:
password requisite pam_pwquality.so try_first_pass local_users_only retry=3 authtok_type=
password sufficient pam_unix.so sha512 shadow nullok try_first_pass use_authtok
在 pam_unix.so 行中添加 noupdate 选项:
password sufficient pam_unix.so sha512 shadow nullok try_first_pass use_authtok noupdate
修改完成后,使用 chage -l 命令再次检查用户的密码策略。
浙公网安备 33010602011771号