linux系统批量创建用户
2015-07-23 11:03
483 查看
脚本目的:批量创建linux系统用户说明:要创建用户的主机密码写入到ip.txt文件中[root@thsf02 scripts]# cat ip.txt
10.165.123.0
10.172.4.150
10.165.122.77
----
#!/bin/bash
user=root
pass=BJTY01230dic
for ip in `cat ip.txt`
do
/usr/bin/expect -c "
set timeout 60
spawn ssh $user@"$ip"
set timeout 60
expect {
\"*yes/n*\" { send \"yes\r\" ; exp_continue }
\"*assword:*\" { send \"$pass\r\" }
}
expect \"\n\"
send \"sleep 1\r\"
send \"useradd test\r\"
send \"sleep 1\r\"
send \"echo \'1qaz2wsx\' | passwd --stdin test\r\"
expect eof"
done
10.165.123.0
10.172.4.150
10.165.122.77
----
#!/bin/bash
user=root
pass=BJTY01230dic
for ip in `cat ip.txt`
do
/usr/bin/expect -c "
set timeout 60
spawn ssh $user@"$ip"
set timeout 60
expect {
\"*yes/n*\" { send \"yes\r\" ; exp_continue }
\"*assword:*\" { send \"$pass\r\" }
}
expect \"\n\"
send \"sleep 1\r\"
send \"useradd test\r\"
send \"sleep 1\r\"
send \"echo \'1qaz2wsx\' | passwd --stdin test\r\"
expect eof"
done
相关文章推荐
- linux 多线程编程
- Linux关掉某个端口
- linux 系统 磁盘标识含义 磁盘相关命令
- CentOS 修改主机名
- 2.Zedboard学习笔记之(二)安装linaro
- centos中mysql重置密码
- linux 应用程序的执行过程详解
- centos7 vim 编辑器自动开启行号
- centos Kill -HUP详解
- linux下统计当前目录下文件个数
- linux下开发串口遇到的问题记录
- 使用python远程操作linux服务器
- 怎么查看在centos中创建的用户组
- linux fork 函数
- 懒人的python——一次执行多条linux命令
- linux&android休眠唤醒
- Linux -- 是一个操作系统,1991年由linus Torvalds发布的,核心是kernel版本号
- RHEL6设置本地YUM源
- Linux 查看CPU信息、机器型号等硬件信息
- centos 安装 boost