Skip to content

Eternal Center

  • System (系统)
  • Services (服务)
  • Databases (数据库)
  • Clusters (集群)
  • Big Data (大数据)
  • Cloud Computing (云计算)
  • Languages (语言)
  • Project (项目)
  • Writings (写作)
  • Eternity (永恒)
  • News (消息)
  • Chronicle (编年史)
  • Words (言)
Posted on August 6, 2020April 2, 2022 by Mingyu Zhu

[步骤] Linux 密码策略的设置 (设置密码复杂度) (CentOS Linux 8 & RHEL 8 版)

步骤目录:

步骤一:设置密码必须包含大小写字母等策略
1.1 生成设置密码必须包含大小写字母的策略文件
1.2 设置密码必须包含大小写字母等策略

步骤二:设置新密码不能和旧密码重复的策略
2.1 修改 password-auth 文件
2.2 修改 system-auth 文件

具体的操作步骤:

步骤一:设置密码必须包含大小写字母等策略
1.1 生成设置密码必须包含大小写字母的策略文件

# authselect list
- nis                            Enable NIS for system authentication
- sssd                           Enable SSSD for system authentication (also for local users only)
- winbind                        Enable winbind for system authentication
- custom/password-policy         Enable SSSD for system authentication (also for local users only)

(
注意:如果没有 custom/password-policy 文件则进行以下操作:

# authselect create-profile password-policy -b sssd --symlink-meta --symlink-pam
# authselect select custom/password-policy
# authselect current
Profile ID: custom/password-policy
Enabled features: None

)

1.2 设置密码必须包含大小写字母等策略

# vim /etc/security/pwquality.conf

将部分内容修改如下:

......
minlen = 15
......
dcredit = -1
......
ucredit = -1
......
lcredit = -1
......
ocredit = -1
......
dictcheck = 1
......
usercheck = 1
......

(
补充:这里以
1) 密码最小长度为 15 个字符
2) 密码包含数字的个数,-1 代表必须包含
3) 密码包含大写字母的个数,-1 代表必须包含
4) 密码包含小写字母的个数,-1 代表必须包含
5) 密码包含特殊字符的个数,-1 代表必须包含
6) 检查密码中是否包含字典
7) 检查密码中是否包含用户
)

步骤二:设置新密码不能和旧密码重复的策略
2.1 修改 password-auth 文件

# vim /etc/authselect/custom/password-policy/password-auth

将以下内容:

......
password.*requisite.*pam_pwhistory.so
......

修改为:

...... 
password    requisite     pam_pwhistory.so remember=5 use_authtok
......

(补充:这里以新密码不能和前 5 个旧密码重复为例)

2.2 修改 system-auth 文件

# vim /etc/authselect/custom/password-policy/system-auth

将以下内容:

......
password.*requisite.*pam_pwhistory.so
......

修改为:

...... 
password    requisite    pam_pwhistory.so remember=5 use_authtok

(补充:这里以新密码不能和前 5 个旧密码重复为例)

CategoriesChinese (中文), System (系统), System Login Security (系统登录安全), System Network & System Security & System Log (系统网络 & 系统安全 & 系统日志), System Security (系统安全)

Post navigation

Previous PostPrevious [工具] Shell 批量修改多个远程服务器某一个用户的过期密码
Next PostNext [步骤] Linux 文件或目录的查找 (特殊权限)

Aspiration (愿景):

Everyone can achieve self achievement and self happiness fairly

每个人都能公平地实现自我成就和自我幸福

Position (位置):

Running on Evolution Host and DigitalOcean

正在 Evolution Host 和 DigitalOcean 上运行

Logo (徽标):

Additional Information (其他信息):

About Manual Clone Contact Disclaimer Donation Friendly Links 关于 说明书 克隆 联系 免责申明 捐赠 友情链接

Standby IP Address (备用 IP 地址):

152.69.204.95  150.230.63.10  Please configure before use / 请先配置再使用

Search Outside Website (站外搜索):

Google Wikipedia Bing
Proudly powered by LNMP Proudly powered by WordPress