# 寫在前面,下面的方法是針對centos7版本的,centos6pam認證模塊用的是pam_cracklib.so
設置密碼中至少包含一個小寫字符,執行命令:
# authconfig --enablereqlower --update
查看設置:# grep "^lcredit" /etc/security/pwquality.conf\
設置密碼中至少包含一個大寫字符,執行命令:
# authconfig --enablerequpper --update
查看設置:
# grep "^ucredit" /etc/security/pwquality.conf
設置密碼中至少包含一個數字字符,執行命令:
# authconfig --enablereqdigit --update
查看設置:
# grep "^dcredit" /etc/security/pwquality.conf
設置密碼中至少包含一個特殊字符,執行命令:
# authconfig --enablereqother --update
查看設置:
# grep "^ocredit" /etc/security/pwquality.conf
直接編輯 /etc/security/pwquality.conf 這個文件 添加上述參數也是可以的
如果想讓上述密碼策略同樣適用於root用戶,那么就需要編輯文件
# vim /etc/pam.d/system-auth 文件,找到 password requisite pam_pwquality.so 這一行,添加如下語句
password requisite pam_pwquality.so try_first_pass local_users_only retry=3 enforce_for_root
有些同學還在看別的博客上寫的加固策略,配置方法如下
password requisite pam_cracklib.so try_first_pass retry=3 type= minlen=16 ucredit=-1 lcredit=-1 ocredit=-1 dcredit=-1
發現這個策略在centos7下並不生效 ,這是因為上面的語句是適用於centos6的加固方法,如果非要用在7上面,可以把它放在
password requisite pam_pwquality.so 這一行的前面就可以了
參考鏈接:
http://topspeedsnail.com/linux-password-limit-lengh-and-complex/