安裝軟件包:yum install expect
腳本功能,從服務器做信任到192.168.101.75-99的IP地址的服務器。
腳本內容:
#!/usr/bin/expect
set timeout 60
for {set i 75} {$i<100} {incr i} {
spawn ssh-copy-id [email protected].$i
expect {
"(yes/no)?"
{
send "yes\n"
expect "*assword:" {send "myself_password\n"}
}
"*assword:"
{
send "myself_password\n"
}
}
}