Linux(CentOS)用户修改密码有效期

1/先查看用户密码过期时间:

[root@01 ~]# chage -l testuser
Last password change     : Jul 10, 2017
Password expires     : Oct 08, 2018
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    : 10

2/用命令修改过期时间为永久,然后查看Password expires:never和Maximum number of days between password change:99999修改成功

复制代码
[root@01 ~]# chage -M 99999 testuser
[root@01 ~]# chage -l testuser
Last password change                    : Jul 10, 2017
Password expires                    : never
Password inactive                    : never
Account expires                        : Oct 16, 2243
Minimum number of days between password change        : 0
Maximum number of days between password change        : 99999
Number of days of warning before password expires    : 10
复制代码

3/补充知识:chage命令用法:

复制代码
chage:密码失效是通过此命令来管理的。
  
  参数意思:
  -m 密码可更改的最小天数。为零时代表任何时候都可以更改密码。
  -M 密码保持有效的最大天数。
  -W 用户密码到期前,提前收到警告信息的天数。
  -E 帐号到期的日期。过了这天,此帐号将不可用。
  -d 上一次更改的日期
  -I 停滞时期。如果一个密码已过期这些天,那么此帐号将不可用。
  -l 例出当前的设置。由非特权用户来确定他们的密码或帐号何时过期。
复制代码

4/常用实例:

复制代码
[root@localhost ~]# chage -l test      #查看用户密码设定情况
最近一次密码修改时间                  : 4月 27, 2018
密码过期时间                         : 从不
密码失效时间                         : 从不
帐户过期时间                         : 从不
两次改变密码之间相距的最小天数          :-1
两次改变密码之间相距的最大天数          :-1
在密码过期之前警告的天数               :-1
 
[root@localhost ~]# chage -M 90 test        #密码有效期90天
 
[root@localhost ~]# chage -d 0 test       #强制用户登陆时修改口令
 
[root@localhost ~]# chage -d 0 -m 0 -M 90 -W 15 test   #强制用户下次登陆时修改密码,并且设置密码最低有效期0和最高有限期90,提前15天发警报提示
 
[root@localhost ~]# chage -E '2014-09-30' test  # test这个账号的有效期是2014-09-30
复制代码

或:

复制代码
vim /etc/login.defs

#修改如下参数
 PASS_MAX_DAYS 90#设置登录密码有效期90天
 PASS_MIN_DAYS 1  #登录密码最短修改时间,增加可以防止非法用户短期更改多次
 PASS_MIN_LEN 8  #登录密码最小长度8位
 PASS_WARN_AGE 7 #登录密码过期提前7天提示修改
 FAIL_DELAY 10 #登录错误时等待时间10秒
 FAILLOG_ENAB yes #登录错误记录到日志
 SYSLOG_SU_ENAB yes #当限定超级用户管理日志时使用
 SYSLOG_SG_ENAB yes #当限定超级用户组管理日志时使用
 MD5_CRYPT_ENAB yes #当使用md5为密码的加密方法时使用
复制代码

 

posted @   hc执迷不悟  阅读(694)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
点击右上角即可分享
微信分享提示