码迷,mamicode.com
首页 > 系统相关 > 详细

自动互信脚本shell/expect

时间:2018-07-16 16:20:46      阅读:249      评论:0      收藏:0      [点我收藏+]

标签:word   note   ash   nod   cal   hostname   auto   dir   index   

cat >forallHost.sh
#!/bin/bash
for i in {1..9}
do
/usr/bin/expect autoyes.sh $i
done

cat >autoyesMkdir.sh
#!/usr/bin/expect
set time 1
set i [ lindex $argv 0 ]
spawn ssh 192.168.4.$i "mkdir /root/.ssh"
expect {
"password:" {send "123456\n"}
"#" {send "hostname\n"}
}

cat >autoyesUprsa.sh
#!/usr/bin/expect
set time 1
set i [ lindex $argv 0 ]
spawn scp -r /root/.ssh 192.168.4.$i:/root/.ssh
expect {
"password:" {send "123456\n"}
"#" {send "hostname\n"}
}

##################################################################3
cat uprsa.sh
#!/bin/bash -r /root/.ssh/ 192.168.4.$i:/root/.ssh/.
for i in {1..9}
do
scp -r /root/.ssh/
192.168.4.$i:/root/.ssh/.
done

cat startvm.sh
#!/bin/bashsh start rh7_node$i
for i in {1..9}
do
virsh start rh7_node$i
done

cat note
local ip --> 76.121.210.172
172.25.254.250
server -->172.25.0.11

cat forallHost.sh
#!/bin/bash
for i in {1..9}
do
expect autoues.sh $i
done

cat autoyes.sh
#!/usr/bin/expect
set time 1
set i [ lindex $argv 0 ]
spawn ssh 192.168.4.$i "mkdir /root/.ssh"
expect {
"password:" {send "123456\n"}
"#" {send "hostname\n"}
}

cat autoyesUprsa.sh
#!/usr/bin/expect
set time 1
set i [ lindex $argv 0 ]
spawn scp -r /root/.ssh 192.168.4.$i:/root/.ssh
expect {
"password:" {send "123456\n"}
"#" {send "hostname\n"}
}

自动互信脚本shell/expect

标签:word   note   ash   nod   cal   hostname   auto   dir   index   

原文地址:http://blog.51cto.com/creatoryuan/2144514

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!