shell结合expect进行批量更改root密码.txt
2013-01-31 13:18
555 查看
shell结合expect进行批量更改root密码
[root@p1 python]# cat /root/serverlist.txt
10.0.1.20
10.0.1.31
root@p1 python]# cat test.sh
#!/bin/bash
cat /root/serverlist.txt|while read line
do
echo "###$(date) changing $line 's user password ###"
echo
expect root.sh $line &> /dev/null
done
[root@p1 python]# cat root.sh
#!/usr/bin/expect -f
set ip [lindex $argv 0]
set password hello123
set name root
set cmd "echo hello \| passwd --stdin root"
spawn ssh $name@$ip $cmd
expect "root@$ip's password:"
send "$password\r"
expect eof
[root@p1 python]# ./test.sh
###Fri Jan 18 16:49:42 CST 2013 changing pongo server 's user password ###
######Fri Jan 18 16:49:42 CST 2013 changing 10.0.1.20 's user password ######
######Fri Jan 18 16:49:43 CST 2013 changing 10.0.1.31 's user password ######
本文出自 “成功来源于分享” 博客,请务必保留此出处http://linuxchina.blog.51cto.com/938835/1130159
[root@p1 python]# cat /root/serverlist.txt
10.0.1.20
10.0.1.31
root@p1 python]# cat test.sh
#!/bin/bash
cat /root/serverlist.txt|while read line
do
echo "###$(date) changing $line 's user password ###"
echo
expect root.sh $line &> /dev/null
done
[root@p1 python]# cat root.sh
#!/usr/bin/expect -f
set ip [lindex $argv 0]
set password hello123
set name root
set cmd "echo hello \| passwd --stdin root"
spawn ssh $name@$ip $cmd
expect "root@$ip's password:"
send "$password\r"
expect eof
[root@p1 python]# ./test.sh
###Fri Jan 18 16:49:42 CST 2013 changing pongo server 's user password ###
######Fri Jan 18 16:49:42 CST 2013 changing 10.0.1.20 's user password ######
######Fri Jan 18 16:49:43 CST 2013 changing 10.0.1.31 's user password ######
本文出自 “成功来源于分享” 博客,请务必保留此出处http://linuxchina.blog.51cto.com/938835/1130159
相关文章推荐
- 使用perl的expect在禁止root登陆的情况下批量修改root密码
- Linux命令(27):shell 结合expect,多服务器批量分发数据
- shell结合expect写的批量scp脚本工具
- shell结合expect写的批量scp脚本工具
- Linux无交互式shell 有root密码下使用expect执行root命令
- centos7进入单用户模式进行root用户的用户密码的更改
- 通过shell脚本实现批量更改密码
- expect 批量修改root密码
- shell结合expect写的批量scp脚本工具
- shell结合expect写的批量scp脚本工具
- 结合ansible 和 js commander 写的批量修改 linux root密码的程序
- shell结合expect写的批量scp脚本工具
- Linux下shell调用expect进行批量升级
- 批量修改root密码#shell脚本
- Shell结合Expect实现自动输入密码
- 如何对更改internet密码所需的缓存时间进行调整?
- 更改mysql自带root用户密码
- linux下更改root用户的密码 以及VIM编辑器使用命令 :q,:x :w :q!
- mysql数据库root用户密码忘记进行修改的办法
- shell结合expect实现堡垒机的跳转功能