设置 Linux 用户密码过期

ano*_*ard 2 linux password

如何在 Linux 中为用户帐户设置密码过期策略?每个发行版是否有很大不同?

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

[找不到重复的 Q,但请告诉我]

scl*_*son 5

我发布得有点快,看起来 passwd 和 chage 都可以满足您想要完成的任务:

sudo chage [username] 将允许您以交互方式进行设置。否则这里是 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
Run Code Online (Sandbox Code Playgroud)

命令 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
Run Code Online (Sandbox Code Playgroud)