您的位置:首页 > 运维架构 > Shell

shell添加用户时设置密码脚本

2011-12-09 10:23 399 查看
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随机生成十位密码脚本 ############
本文出自 “游造技术博客” 博客,请务必保留此出处http://youzao.blog.51cto.com/3946111/737799
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: