加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

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

发布时间:2020-12-15 07:16:38 所属栏目:安全 来源:网络整理
导读: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:/

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随机生成十位密码脚本 ############


(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读