![linux下如何禁用账户过期以及过期后强制修改密码?](https://linux22.com/image/113509/linux%E4%B8%8B%E5%A6%82%E4%BD%95%E7%A6%81%E7%94%A8%E8%B4%A6%E6%88%B7%E8%BF%87%E6%9C%9F%E4%BB%A5%E5%8F%8A%E8%BF%87%E6%9C%9F%E5%90%8E%E5%BC%BA%E5%88%B6%E4%BF%AE%E6%94%B9%E5%AF%86%E7%A0%81%EF%BC%9F.png)
我想将密码过期更改为非过期,为此我使用了以下命令
[root@test-host ~]# chage -l test
Last password change : password must be changed
Password expires : password must be changed
Password inactive : password must be changed
Account expires : never
Minimum number of days between password change : 0
chage -m 0 -M 99999 -I -1 -E -1 test
[root@test-host ~]# chage -l test
Last password change : Jun 10, 2017
Password expires : never
Password inactive : never
Account expires : never
Minimum number of days between password change : 0
Maximum number of days between password change : 99999
Number of days of warning before password expires : 7
但是,尽管它现在处于非过期状态,但它要求我更改密码。所以无论如何都要在过期后禁止更改现有密码
test@test-host's password:
You are required to change your password immediately (root enforced)
Last login: Wed Jun 14 01:28:07 2017 from
WARNING: Your password has expired.
You must change your password now and login again!
Changing password for user test.
Changing password for test.
答案1
你有没有尝试过:
passwd -x -1 -n -1 -w -1 ${USER}
它可能会产生相同的结果,但它可以达到目的。