shell批量添加使用者時随機生成密碼腳本
vi useradd.sh
#!/bin/bash
i=1
while [ $i -le 5 ]
do
useradd red$i
a=`sh ./passwd.sh`
echo " red$i:$a " >> userpasswd
echo red$i:$a|chpasswd
let i++
done
執行:sh useradd.sh
[root@2 shell]# cat /etc/passwd|grep red
red1:x:515:515::/home/red1:/bin/bash
red2:x:516:516::/home/red2:/bin/bash
red3:x:517:517::/home/red3:/bin/bash
red4:x:518:518::/home/red4:/bin/bash
red5:x:519:519::/home/red5:/bin/bash
[root@2 shell]# cat userpasswd
red1:$Ca7%298d2
red2:eEaBBB7Fb4
red3:%3E385cecE
red4:3@F%@B0584
red5:AdEe^6BF$F
[root@2 shell]# su red1
[red1@2 shell]$ su red2
密碼:
[red2@2 shell]$
##############passwh.sh在本部落格中的 shell随機生成十位密碼腳本 ############