CentOS 7 設置密碼規則


出於安全考慮設置密碼規則

1、設置密碼過期的天數。 用戶必須在幾天內更改密碼。 此設置僅在創建用戶時才會產生影響,而不會影響到現有用戶。 如果設置為現有用戶,請運行命令“chage -M(days)(user)”

[root@shaonbean ~]# vi /etc/login.defs
# line 25: set 60 for Password Expiration
PASS_MAX_DAYS 60



2、設置可用密碼的最短天數。 至少在改變它之后,用戶必須至少使用他們的密碼。 此設置僅在創建用戶時才會產生影響,而不會影響到現有用戶。 如果設置為現有用戶,請運行命令“chage -m(days)(user)”

[root@shaonbean ~]# vi /etc/login.defs
# line 26: set 2 for Minimum number of days available
PASS_MIN_DAYS 2


3、在到期前設置警告的天數。 此設置僅在創建用戶時才會產生影響,而不會影響到現有用戶。 如果設置為存在用戶,請運行命令“chage -W(days)(user)”

[root@shaonbean ~]# vi /etc/login.defs
# line 28: set 7 for number of days for warnings
PASS_WARN_AGE 7
  

4、使用過去使用的密碼進行限制。 在這一代中,用戶不能設置相同的密碼。

[root@shaonbean ~]# 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

5、設置最小密碼長度。 用戶不能將密碼長度設置為小於此參數。

# set 8 for minimum password length
[root@shaonbean ~]# authconfig --passminlen=8 --update
# the parameter is set in a config below
[root@shaonbean ~]# grep "^minlen" /etc/security/pwquality.conf
minlen = 8


6、為新密碼設置所需的最少字符類數。 (種類⇒UpperCase / LowerCase / Digits / Others)

# set 2 for minimum number of required classes of characters
[root@shaonbean ~]# authconfig --passminclass=2 --update
# the parameter is set in a config below
[root@shaonbean ~]# grep "^minclass" /etc/security/pwquality.conf
minclass = 2


7、在新密碼中設置允許的連續相同字符的最大數量。

# set 2 for maximum number of allowed consecutive same characters
[root@shaonbean ~]# authconfig --passmaxrepeat=2 --update
# the parameter is set in a config below
[root@shaonbean ~]# grep "^maxrepeat" /etc/security/pwquality.conf
maxrepeat = 2


8、在新密碼中設置同一類的最大允許連續字符數。


# set 4 for maximum number of allowed consecutive characters of the same class
[root@shaonbean ~]# authconfig --passmaxclassrepeat=4 --update
# the parameter is set in a config below
[root@shaonbean ~]# grep "^maxclassrepeat" /etc/security/pwquality.conf
maxclassrepeat = 4


9、新密碼中至少需要一個小寫字符

[root@shaonbean ~]# 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)
[root@shaonbean ~]# grep "^lcredit" /etc/security/pwquality.conf
lcredit = -1


10、新密碼中至少需要一個大寫字符

[root@shaonbean ~]# 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)
[root@shaonbean ~]# grep "^ucredit" /etc/security/pwquality.conf
ucredit = -1


11、新密碼中至少需要一位數字

[root@shaonbean ~]# 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)
[root@shaonbean ~]# grep "^dcredit" /etc/security/pwquality.conf
dcredit = -1


12、新密碼中至少需要一個其他字符

[root@shaonbean ~]# 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)
[root@shaonbean ~]# grep "^ocredit" /etc/security/pwquality.conf
ocredit = -1


13、在新密碼中設置單調字符序列的最大長度。 (ex⇒’12345’,’fedcb’)

[root@shaonbean ~]# vi /etc/security/pwquality.conf
# add to the end
maxsequence = 3

14、設置舊密碼中不能出現的新密碼中的字符數。

[root@shaonbean ~]# vi /etc/security/pwquality.conf
# add to the end
difok = 5


15、檢查新密碼中是否包含用戶passwd項的GECOS字段中長度超過3個字符的單詞

[root@shaonbean ~]# vi /etc/security/pwquality.conf
# add to the end
gecoscheck = 1

16、設置不能包含在密碼中的Ssace分隔列表。


[root@shaonbean ~]# vi /etc/security/pwquality.conf
# add to the end
badwords = denywords1 denywords2 denywords3

17、為新密碼設置散列/密碼算法。 (默認是sha512)

# show current algorithm
[root@shaonbean ~]# authconfig --test | grep hashing
password hashing algorithm is md5
# chnage algorithm to sha512
[root@shaonbean ~]# authconfig --passalgo=sha512 --update
[root@shaonbean ~]# authconfig --test | grep hashing
password hashing algorithm is sha512

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM