搜索
查看: 4578|回复: 0

CentOS7 设置用户密码规则

[复制链接]

330

主题

177

回帖

1071

积分

vip用户

积分
1071

注册会员活跃会员热心会员

QQ
发表于 2018-4-18 12:44:34 | 显示全部楼层 |阅读模式
weixin.gif

出于安全原因设置密码规则

1、设置密码过期的天数。 用户必须在几天内更改密码。 此设置仅在创建用户时才会产生影响,而不会影响到现有用户。 如果设置为现有用户,请运行命令“chage -M(days)(user)”

  1. [root@shaonbean ~]# vi /etc/login.defs
  2. # line 25: set 60 for Password Expiration
  3. PASS_MAX_DAYS 60
复制代码

2、设置可用密码的最短天数。 至少在改变它之后,用户必须至少使用他们的密码。 此设置仅在创建用户时才会产生影响,而不会影响到现有用户。 如果设置为现有用户,请运行命令“chage -m(days)(user)”

  1. [root@shaonbean ~]# vi /etc/login.defs
  2. # line 26: set 2 for Minimum number of days available
  3. PASS_MIN_DAYS 2
复制代码

3、在到期前设置警告的天数。 此设置仅在创建用户时才会产生影响,而不会影响到现有用户。 如果设置为存在用户,请运行命令“chage -W(days)(user)”

  1. [root@shaonbean ~]# vi /etc/login.defs
  2. # line 28: set 7 for number of days for warnings
  3. PASS_WARN_AGE 7
复制代码

4、使用过去使用的密码进行限制。 在这一代中,用户不能设置相同的密码。

  1. [root@shaonbean ~]# vi /etc/pam.d/system-auth
  2. # near line 15: prohibit to use the same password for 5 generation in past
  3. password     sufficient     pam_unix.so sha512 shadow nullok try_first_pass use_authtok remember=5
复制代码

5、设置最小密码长度。 用户不能将密码长度设置为小于此参数。

  1. # set 8 for minimum password length
  2. [root@shaonbean ~]# authconfig --passminlen=8 --update
  3. # the parameter is set in a config below
  4. [root@shaonbean ~]# grep "^minlen" /etc/security/pwquality.conf
  5. minlen = 8
复制代码

6、为新密码设置所需的最少字符类数。 (种类⇒UpperCase / LowerCase / Digits / Others)

  1. # set 2 for minimum number of required classes of characters
  2. [root@shaonbean ~]# authconfig --passminclass=2 --update
  3. # the parameter is set in a config below
  4. [root@shaonbean ~]# grep "^minclass" /etc/security/pwquality.conf
  5. minclass = 2
复制代码

7、在新密码中设置允许的连续相同字符的最大数量。

  1. # set 2 for maximum number of allowed consecutive same characters
  2. [root@shaonbean ~]# authconfig --passmaxrepeat=2 --update
  3. # the parameter is set in a config below
  4. [root@shaonbean ~]# grep "^maxrepeat" /etc/security/pwquality.conf
  5. maxrepeat = 2
复制代码

8、在新密码中设置同一类的最大允许连续字符数。

  1. # set 4 for maximum number of allowed consecutive characters of the same class
  2. [root@shaonbean ~]# authconfig --passmaxclassrepeat=4 --update
  3. # the parameter is set in a config below
  4. [root@shaonbean ~]# grep "^maxclassrepeat" /etc/security/pwquality.conf
  5. maxclassrepeat = 4
复制代码

9、新密码中至少需要一个小写字符

  1. [root@shaonbean ~]# authconfig --enablereqlower --update
  2. # the parameter is set in a config below
  3. # (if you'd like to edit the value, edit it with vi and others)
  4. [root@shaonbean ~]# grep "^lcredit" /etc/security/pwquality.conf
  5. lcredit = -1
复制代码

10、新密码中至少需要一个大写字符

  1. [root@shaonbean ~]# authconfig --enablerequpper --update
  2. # the parameter is set in a config below
  3. # (if you'd like to edit the value, edit it with vi and others)
  4. [root@shaonbean ~]# grep "^ucredit" /etc/security/pwquality.conf
  5. ucredit = -1
复制代码

11、新密码中至少需要一位数字

  1. [root@shaonbean ~]# authconfig --enablereqdigit --update
  2. # the parameter is set in a config below
  3. # (if you'd like to edit the value, edit it with vi and others)
  4. [root@shaonbean ~]# grep "^dcredit" /etc/security/pwquality.conf
  5. dcredit = -1
复制代码

t0167eb2f68578e3439.jpg



有没有参加CTF比赛的,一起组队啊!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表