Skip to content
Eternal Center

Eternal Center

  • System (系统)
  • Services (服务)
  • Databases (数据库)
  • Clusters (集群)
  • Big Data (大数据)
  • Cloud Computing (云计算)
  • Languages (语言)
  • Project (项目)
  • Writings (写作)
  • Eternity (永恒)
  • News (消息)
  • Chronicle (编年史)
  • Words (言)
Posted on 31/07/202126/12/2021 by Mingyu Zhu

[步骤] Linux 输错密码次数限制的设置 (CentOS&RHEL 版)

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

# 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

)

步骤二:配置 /etc/authselect/custom/password-policy/system-auth 文件

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

先删除包含以下内容的行:

......
......pam_faillock.so......
......

再将以下内容:

......
password    requisite                                    pam_pwquality.so try_first_pass local_users_only
......
auth        required                                     pam_faillock.so preauth silent                         {include if "with-faillock"}
......
auth        required                                     pam_faillock.so authfail                               {include if "with-faillock"}
......

修改为:

......
password    requisite                                    pam_pwquality.so try_first_pass local_users_only retry=5
......
auth        required                                     pam_faillock.so preauth
......
auth        required                                     pam_faillock.so authfail
......

(补充:这里的 retry=5 代表重复尝试 5 次后登陆会被锁住)

步骤三:配置 /etc/authselect/custom/password-policy/system-password 文件

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

先删除包含以下内容的行:

......
......pam_faillock.so......
......

再将以下内容:

......
password    requisite                                    pam_pwquality.so try_first_pass local_users_only
......
auth        required                                     pam_faillock.so preauth silent                         {include if "with-faillock"}
......
auth        required                                     pam_faillock.so authfail                               {include if "with-faillock"}
......

修改为:

......
password    requisite                                    pam_pwquality.so try_first_pass local_users_only retry=5
......
auth        required                                     pam_faillock.so preauth
......
auth        required                                     pam_faillock.so authfail
......

(补充:这里的 retry=5 代表重复尝试 5 次后登陆会被锁住)

步骤四:配置 /etc/security/faillock.conf 文件

将以下内容:

......
# deny = 3
......
# unlock_time = 600
......

修改为:

......
deny = 30
......
unlock_time = 600
......

(补充:这里的 deny = 30 和 unlock_time = 600 代表拒绝 30 次 600 秒后解锁)

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

Post navigation

Previous PostPrevious [工具] Python 一个脚本调用另一个脚本的函数执行 Linux 命令并返回执行结果
Next PostNext [步骤] Linux 全局加密 SSL 的设置 (CentOS 8 & RHEL 8 版)

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