🗒️centos7 pam密码策略
2023-4-14
| 2023-5-18
0  |  0 分钟
type
status
date
slug
summary
tags
category
icon
password

1. 口令重复检查

找到配置文件/etc/pam.d/system-auth的password requisite pam_pwquality.so try_first_pass local_users_only retry=3 authtok_type= 下方新增一行:
password sufficient pam_unix.so use_authtok remember=5 password required pam_pwhistory.so use_authtok remember=5
💡
remember=5 禁止使用最近5次历史密码

2. 口令复杂度

2.1 改/etc/security/pwquality.conf

pam_pwquality模块用于根据一组规则检查密码的强度。其过程由两个步骤组成:首先检查提供的密码是否在字典中找到。如果没有,它会继续执行几个附加检查。pam_pwquality  与 /etc/pam.d/passwd文件的密码组件中的其他 PAM 模块一起堆叠,自定义规则集在 /etc/security/pwquality.conf配置文件中指定。
要使用 pam_quality 启用,请在 /etc/pam.d/passwd 文件中的 密码 堆栈中添加以下行:
password required pam_pwquality.so retry=3
检查的选项每行指定一个。例如,若要要求密码长度最少为 8 个字符(包括所有四类字符),请在 /etc/security/pwquality.conf 文件中添加以下行:
minlen = 8 minclass = 4

2.2 改/etc/pam.d/system-auth

更常见的修改方法:
对于CentOS、Fedora、EulerOS操作系统
  1. 执行以下命令,编辑文件“/etc/pam.d/system-auth”。
    1. vi /etc/pam.d/system-auth
  1. 找到文件中的以下内容。
      • 基于Red Hat 7.0的CentOS、Fedora、EulerOS系统:
        • password requisite pam_pwquality.so try_first_pass retry=3 type=
      • 其他CentOS、Fedora、EulerOS系统:
        • password requisite pam_cracklib.so try_first_pass retry=3 type=
  1. 添加参数“minlen”“dcredit”“ucredit”“lcredit”“ocredit”。如果文件中已有这些参数,直接修改参数值即可。说明:
    1. 示例:
      password requisite pam_cracklib.so try_first_pass retry=3 minlen=8 dcredit=-1 ucredit=-1 lcredit=-1 ocredit=-1 type=
      💡
      “dcredit”“ucredit”“lcredit”“ocredit”中均需要配置为负数。
      参数
      说明
      示例
      minlen
      口令最小长度配置项。 若需要设置最小口令长度为8,则minlen的值应该设置为8。
      minlen=8
      dcredit
      口令数字要求的配置项。 值为负数N时表示至少有N个数字,值为正数时对数字个数没有限制。
      dcredit=-1
      ucredit
      口令大写字母要求的配置项。 值为负数N时表示至少有N个大写字母,值为正数时对大写字母个数没有限制。
      ucredit=-1
      lcredit
      口令小写字母要求的配置项。 值为负数N时表示至少有N个小写字母,值为正数时对小写字母个数没有限制。
      lcredit=-1
      ocredit
      特殊字符要求的配置项。 值为负数N时表示至少有N个特殊字符,值为正数时对特殊字符个数没有限制。
      ocredit=-1

3. 参考

 
技术
  • 系统
  • 安全
  • Jenkins slave pod的pipeline实现ansible find的paths & patterns
    目录