设置Linux用户密码到期

如何在Linux中为用户帐户设置密码过期策略? 每个发行版都差别很大吗?

特别是我使用了一些Debian / Ubuntu服务器,但是对于其他发行版的相应信息的链接显然是受欢迎的。

[找不到重复的Q,但是让我知道]

我稍微发布一下,它看起来像passwd和chage将为你想要完成的工作:

sudo chage [用户名]将交互式地让你设置的东西。 否则,这里是chage和passwd的帮助输出。

chage –help输出:chage –help用法:chage [options] [LOGIN]

Options: -d, --lastday LAST_DAY set last password change to LAST_DAY -E, --expiredate EXPIRE_DATE set account expiration date to EXPIRE_DATE -h, --help display this help message and exit -I, --inactive INACTIVE set password inactive after expiration to INACTIVE -l, --list show account aging information -m, --mindays MIN_DAYS set minimum number of days before password change to MIN_DAYS -M, --maxdays MAX_DAYS set maximim number of days before password change to MAX_DAYS -W, --warndays WARN_DAYS set expiration warning days to WARN_DAYS 

从命令passwd输出–​​help –

 passwd --help Usage: passwd [options] [LOGIN] Options: -a, --all report password status on all accounts -d, --delete delete the password for the named account -e, --expire force expire the password for the named account -h, --help display this help message and exit -k, --keep-tokens change password only if expired -i, --inactive INACTIVE set password inactive after expiration to INACTIVE -l, --lock lock the named account -n, --mindays MIN_DAYS set minimum number of days before password change to MIN_DAYS -q, --quiet quiet mode -r, --repository REPOSITORY change password in REPOSITORY repository -S, --status report password status on the named account -u, --unlock unlock the named account -w, --warndays WARN_DAYS set expiration warning days to WARN_DAYS -x, --maxdays MAX_DAYS set maximim number of days before password change to MAX_DAYS 

您可以在/etc/login.defs中设置到期策略 – 特别是PASS_MAX_DAYS =,PASS_MIN_DAYS =和PASS_WARN_AGE =

还需要编辑/ etc / default / useradd – INACTIVE =和EXPIRE =

这不完全相同的情况,但是这里有更多的信息: 过期非活动用户帐户