shell脚本 expect 实现自动登陆
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
贵有恒,何必三更起五更睡;最无益,只怕一日暴十寒