linux自動修改密碼長度和有效期的指令碼

czxin788發表於2015-04-16


#!/bin/bash
rq=`date +%Y%m%d`
echo "The login.defs was copy to the /etc/login.defs.bak$rq"
echo "####################################"
cp /etc/login.defs /etc/login.defs.bak$rq
echo "update password length and days"
echo "####################################"
for i in PASS_MAX_DAYS PASS_MIN_LEN PASS_MIN_DAYS PASS_WARN_AGE
do
cat /etc/login.defs |grep $i|grep -v \#
done
sed  -i '/PASS_MIN_LEN/s/5/8/g' /etc/login.defs
sed  -i '/PASS_MAX_DAYS/s/99999/90/g' /etc/login.defs
echo "###################################"
echo "updated the login.defs"
echo "###################################"
for i in PASS_MAX_DAYS PASS_MIN_LEN PASS_MIN_DAYS PASS_WARN_AGE
do
cat /etc/login.defs |grep $i|grep -v \#
done
echo "##################################"

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28916011/viewspace-1579992/,如需轉載,請註明出處,否則將追究法律責任。

相關文章