vi auto_ssh.exp
#!/usr/bin/expect
set ipaddress "123.227.159.159"
set passwd "你的密码"
set timeout 30
spawn ssh root@$ipaddress
expect {
"yes/no" {send "yes\r";exp_continue}
"password" {send "$passwd\r"} #必须要加\r
}
interact