一、设置密码失效时间
在 /etc/login.defs 中奖PASS_MAX_DAYS 参数设置为60-180之间。 默认为99999
同时执行命令,设置root密码失败时间:
chage --maxdays 90 root
chage: failure while writing changes to /etc/shadow 我的会出现这个提示。
二、设置密码修改最小间隔时间
在 /etc/login.defs 中将 PASS_MIN_DAYS 设置为 7-14
同时执行命令为root用户设置
chage --mindays 7 root
三、设置SSH空闲超时退出时间
编辑/etc/ssh/sshd_config,将ClientAliveInterval 设置为300到900,即5-15分钟,将ClientAliveCountMax设置为0-3之间。
```
ClientAliveInterval 600
ClientAliveCountMax 2
```
四、密码复杂度检查
编辑/etc/security/pwquality.conf,把minlen(密码最小长度)设置为9-32位,把minclass(至少包含小写字母、大写字母、数字、特殊字符等4类字符中等3类或4类)设置为3或4。如:
```
minlen=10
minclass=3
五、检查密码重用是否受限制
在/etc/pam.d/password-auth和/etc/pam.d/system-auth中password sufficient pam_unix.so 这行的末尾配置remember参数为5-24之间,原来的内容不用更改,只在末尾加了remember=5。
六、设置用户权限配置文件的权限
执行以下5条命令 ``` chown root:root /etc/passwd /etc/shadow /etc/group /etc/gshadow chmod 0644 /etc/group chmod 0644 /etc/passwd chmod 0400 /etc/shadow chmod 0400 /etc/gshadow ```