ansible 自动ssh
#!/usr/bin/expect -fset timeout -1
set user test
set passwd "123456"
for { set i 100 } { $i < 120 } { incr i } {
spawn ssh -l $user 172.41.30.$i
expect {
"yes/no" { send "yes\r";exp_continue }
"id_rsa" { send "yes\r";exp_continue }
"*assword" { send "$passwd\r" ;exp_continue }
"test@" {
send "sudo su -\r"
expect {
"password for test" { send "$passwd\r";exp_continue }
}
}
}
}
expect eof
exit 0
页:
[1]