首页 > 开发 > Linux Shell > 正文

shell随机定时修改密码change_passwd.sh

2020-07-27 18:43:15
字体:
来源:转载
供稿:网友

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_passwd0 10 10,25 * * /bin/sh /srv/change_passwd.sh >/dev/null 2>&1

ps:下面看下shell 随机修改密码

#!/bin/bashname=hostnameETH1=""if ifconfig eth1 &> /dev/null;thenETH1=$(ip a | grep -A 0 "eth1" | awk -F "[ /]" '/inet/ {print $3}')fiETH0=$(ip a | grep -A 0 "eth0" | awk -F "[ /]" '/inet/ {print $3}')MATRIX1="0123456789"MATRIX2="ABCDEFGHIJKLMNOPQRSTUVWXYZ"MATRIX3="abcdefghijklmnopqrstuvwxyz"MATRIX4="./*&^%$#@!()"LENGTH="16"ii=1while [ "${n:=1}" -le "$LENGTH" ]; doMATRIX=eval echo "$"MATRIX${ii}PASS="$PASS${MATRIX:$(($RANDOM%${#MATRIX})):1}"let n+=1ii=expr $ii + 1if [ $ii -eq 5 ];thenii=1fidoneecho "$PASS" | passwd root --stdinecho "$ETH1 $ETH0 $name root $PASS" >> /tmp/pass.txtcat /tmp/pass.txtrm -rf /tmp/pass.txt rm -rf /root/test.sh

总结

以上所述是小编给大家介绍的shell随机定时修改密码change_passwd.sh,希望对大家有所帮助!

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表