修改UID大于等于500的用户的密码
方法1:
for i in $(awk -F: '{if($3>500)print $1}' /etc/passwd)
do
pass=$(cat /dev/urandom| tr -dc 'a-zA-Z0-9' | fold -w 8 | head -n 1)
echo $pass | passwd --stdin $i 2&>/dev/null && echo "$name\t$pass\n" >>/tmp/suss
done
方法2:
while read userline
do
uid=`echo $userline|cut -d: -f 3`
user=`echo $userline|cut -d: -f 1`
if [ $uid -gt 499 ]&&[ $user != "nfsnobody" ]
then
echo $user >>/root/pass
newpass=`cat /dev/urandom|sed 's/[^a-zA-Z0-9]//g'|strings -n 8 | head -1`
sed -i "s/$user/& $newpass/g" /root/pass
echo $newpass|passwd $user --stdin
fi
done< /etc/passwd
方法3:
#!/bin/bash
log="passwd.txt"
for i in `awk -F ":" '{if($3>=500)print $1}' /etc/passwd`
do
passwd=`mkpasswd -l 8 -d 1 -c 3 -c 2 -s 2`
echo $passwd | passwd --stdin $i
echo -e "$i\t:$passwd" >> $log
done
转自:
阅读(1124) | 评论(0) | 转发(0) |