shell随机定时修改密码change_passwd.sh
程序员文章站
2023-11-09 13:45:04
change_passwd.sh
#!/bin/sh
/usr/bin/chattr -i /etc/passwd /etc/shadow /etc/group /etc/...
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,希望对大家有所帮助!
上一篇: JS实现手写 forEach算法示例
下一篇: php递归创建目录的方法