如何在 Linux 中强制用户下次登录时更改密码?
operating systemlinuxmca
出于安全考虑,系统中的用户需要定期更新密码。本文将介绍如何强制用户下次登录时更改密码。
列出用户
首先,让我们看看系统中有哪些可用的用户。
$ cut -d: -f1 /etc/passwd
运行上述代码得到以下结果 −
mail news uucp proxy www-data backup list … Ubuntu uname1
检查用户详细信息
接下来,我们检查用户当前密码系统配置的设置。
$ sudo chage -l uname1 [sudo] password for ubuntu:
运行上述代码得到以下结果 −
Last password change: Dec 30, 2019 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
设置 expire 选项
现在我们使用 expire 选项来设置密码过期的时间线,然后使用 chage 查询它来找到已实现的过期时间。
$ sudo passwd --expire uname1 passwd: password expiry information changed. $ sudo chage -l uname1
运行上述代码得到以下结果 −
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 Maximum number of days between password change: 99999 Number of days of warning before password expires: 7
相关文章
有用资源
linux 参考教程 - 该教程包含有关 linux 的更多信息:https://www.cainiaomax.com/linux/

