Automatic mutual trust Script Shell/expect

Source: Internet
Author: User
Tags set time

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

Automatic mutual trust Script Shell/expect

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.