1#!/bin/Bash2#by:[email protected]163. com3dieso=/etc/PAM.D4pamso=$ (ls$DIESO/*|awk-f '/' {print $4} ')5 nepamun= ' password sufficient pam_unix.so MD5 shadow Nullok try_first_pass use_authtok remember=5 '6 For PAMS in $PAMSO;d o7 if [[-N $ (cat "$DIESO/$PAMS" | grep "Shadow" | awk ' {print $} ')]];then8 pamun= "9 pamun=$ (cat "$DIESO/$PAMS" | grep "Shadow" | awk ' {print $} ')Ten if [[-N $ (echo $PAMUN | grep "Remember" | awk ' {print $} ')]];then One echo "The password remember has been set" A Else - sed-i "s/$PAMUN/$NEPAMUN/" $DIESO/$PAMS - fi the fi -
- Done
1#!/bin/SH2#by: [Email protected]163. com3dieso=/etc/PAM.D4pamso=$ (ls$DIESO/*|awk-f '/' {print $4} ')5 nepamun= ' password sufficient pam_unix.so MD5 shadow Nullok try_first_pass use_authtok remember=5 '6 newpasset= ' password requisite pam_cracklib.so retry=3 difok=3 minlen=8 ucredit=-1 lcredit=-2 dcredit=-1 ocredit= -1 '7 #retry = 3 Password retry count is 3 times8 #difok = 3 allows 3 characters in a new password to be the same as the old password9 #minlen = 8 password Minimum length is 8 Note: Invalid root user, root setting other user This parameter is also invalid, the user changes their own password to be effectiveTen #ucredit The =-1 password must contain an uppercase letter One #lcredit =-2 Password must contain a minimum of two lowercase letters A #dcredit The =-1 password must contain a number - #ocredit =-1 Password must contain at least one punctuation mark - [-f/lib/security/pam_cracklib.so] && echo "start config pam_cracklib.so" the For PAMS in $PAMSO;d o - if [[-N $ (cat "$DIESO/$PAMS" | grep pam_cracklib | awk ' {print $} ')]];then - passet= " - passet=$ (cat "$DIESO/$PAMS" | grep "pam_cracklib.so" | awk ' {print $} ') + if [[-N $ (echo $PASSET | grep "Difok" | awk ' {print $} ')]];then - echo "The password complexity rule has been set" + Else A sed-i "s/${passet}/${newpasset}/" $DIESO/$PAMS at fi - fi - - - Done
Limit TTY
#!/bin/SH forTinch$(Cat/etc/securetty |grep "^tty"|grep-V"tty[1,2]$"); DoT="'T=$tsed-I."s/$T/# $T/"/etc/Securetty Done
Linux Password security scripts