出於安全考慮設定密碼規則
設定密碼到期的天數。
使用者必須在天內更改密碼。
此設定僅影響建立使用者,而不會影響現有使用者。
如果設定為現有使用者,請執行命令 “chage -M(days)(user)” 。
PASS_MAX_DAYS   60         # 密碼到期時間
PASS_MIN_DAYS   3          # 初始密碼更改時間
PASS_MIN_LEN    8          # 密碼最小長度
PASS_WARN_AGE   7          # 密碼過期提示時間
重複密碼限制使用
# vi /etc/pam.d/system-auth
# near line 15: prohibit to use the same password for 5 generation in past
password     sufficient     pam_unix.so sha512 shadow nullok try_first_pass use_authtok remember=5
 
設定最小密碼長度,使用者不能設定小於此引數的密碼長度
# set 8 for minimum password length
# authconfig –passminlen=8 –update# the parameter is set in a config below
# grep “^minlen” /etc/security/pwquality.conf
minlen = 8
 
在新密碼中設定同一類的允許連續字元的最大數目
set 4 for maximum number of allowed consecutive characters of the same class
# authconfig –passmaxclassrepeat=4 –update# the parameter is set in a config below
# grep “^maxclassrepeat” /etc/security/pwquality.conf
maxclassrepeat = 4
 
在新密碼中至少需要一個小寫字元。
# authconfig –enablereqlower –update# the parameter is set in a config below# (if you’d like to edit the value, edit it with vi and others)
# grep “^lcredit” /etc/security/pwquality.conf
lcredit = -1
 
在新密碼中至少需要一個大寫字元
# authconfig –enablerequpper –update# the parameter is set in a config below
# (if you’d like to edit the value, edit it with vi and others)
# grep “^ucredit” /etc/security/pwquality.conf
ucredit = -1
 
在新密碼中至少需要一個數字
# authconfig –enablereqdigit –update# the parameter is set in a config below
# (if you’d like to edit the value, edit it with vi and others)
# grep “^dcredit” /etc/security/pwquality.conf
dcredit = -1
 
密碼包括至少一個特殊字元
# authconfig –enablereqother –update# the parameter is set in a config below
# (if you’d like to edit the value, edit it with vi and others)
# grep “^ocredit” /etc/security/pwquality.conf
ocredit = -1
 
在新密碼中設定單調字元序列的最大長度。(ex⇒’12345’,’fedcb’)
[root@linuxprobe~]# vi /etc/security/pwquality.conf# add to the end
maxsequence = 3
# 設定新密碼中不能出現在舊密碼中的字元數
# vi /etc/security/pwquality.conf# add to the end
difok = 5
 
檢查來自使用者 passwd 條目的 GECOS 欄位的長度超過 3 個字元的字是否包含在新密碼中。
# vi /etc/security/pwquality.conf# add to the end
gecoscheck = 1
 
設定不能包含在密碼中的 Ssace 分隔的單詞列表
# vi /etc/security/pwquality.conf# add to the end
badwords = denywords1 denywords2 denywords3
 
為新密碼設定 hash / crypt 演演算法。(預設為 sha512)# show current algorithm
# authconfig –test | grep hashing
password hashing algorithm is md5# chnage algorithm to sha512
# authconfig –passalgo=sha512 –update
# authconfig –test | grep hashing
password hashing algorithm is sha512