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