shell script.ssh自动应答脚本

#!/usr/bin/expect
set user [lindex $argv 0] #参数1:用户名
set ip [lindex $argv 1] #参数2:ip
set password [lindex $argv 2] #参数3:密码
spawn ssh ${user}@$ip
expect {
    "(yes/no)?"
        { send "yes\r";exp_continue}
    "password:"
        { send "$password\n"}
}
interact
 

posted @ 2017-03-08 16:46  puer633  阅读(546)  评论(0编辑  收藏  举报