自動互信腳本shell/expect

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"}
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章