shell随机定时修改密码change_passwd.sh
change_passwd.sh
#!/bin/sh /usr/bin/chattr -i /etc/passwd /etc/shadow /etc/group /etc/gshadow /usr/bin/echo `/usr/bin/date +%Y%m%d%w` |/usr/bin/awk -F '' '{print $1$5$9"Jack_Cui"$3$5$7}' |/usr/bin/passwd --stdin root /usr/bin/chattr +i /etc/passwd /etc/shadow /etc/group /etc/gshadow
定时任务 crontab -e
#change_passwd 0 10 10,25 * * /bin/sh /srv/change_passwd.sh >/dev/null 2>&1
ps:下面看下shell 随机修改密码
#!/bin/bash name=hostname ETH1="" if ifconfig eth1 &> /dev/null;then ETH1=$(ip a | grep -A 0 "eth1" | awk -F "[ /]" '/inet/ {print $3}') fi ETH0=$(ip a | grep -A 0 "eth0" | awk -F "[ /]" '/inet/ {print $3}') MATRIX1="0123456789" MATRIX2="ABCDEFGHIJKLMNOPQRSTUVWXYZ" MATRIX3="abcdefghijklmnopqrstuvwxyz" MATRIX4="./*&^%$#@!()" LENGTH="16" ii=1 while [ "${n:=1}" -le "$LENGTH" ]; do MATRIX=eval echo "$"MATRIX${ii} PASS="$PASS${MATRIX:$(($RANDOM%${#MATRIX})):1}" let n+=1 ii=expr $ii + 1 if [ $ii -eq 5 ];then ii=1 fi done echo "$PASS" | passwd root --stdin echo "$ETH1 $ETH0 $name root $PASS" >> /tmp/pass.txt cat /tmp/pass.txt rm -rf /tmp/pass.txt rm -rf /root/test.sh
总结
以上所述是小编给大家介绍的shell随机定时修改密码change_passwd.sh,希望对大家有所帮助!
相关推荐
liguojia 2020-10-20
xiaonamylove 2020-10-16
woaimeinuo 2020-10-21
tianhuak 2020-11-24
huha 2020-10-16
lianshaohua 2020-09-23
laisean 2020-11-11
zhangjie 2020-11-11
大牛牛 2020-10-30
firefaith 2020-10-30
wangzhaotongalex 2020-10-20
以梦为马不负韶华 2020-10-20
CARBON 2020-10-20
彼岸随笔 2020-10-20
lianshaohua 2020-10-20
yutou0 2020-10-17
JohnYork 2020-10-16
Julyth 2020-10-16
applecarelte 2020-10-16