mac 自动登录linux ssh

#!/usr/bin/expect -f

set timeout 60

set user 账号
set host IP地址
set password 密码

spawn ssh $user@$host
expect {
    "yes/no" {
        send "yes\r";exp_continue
    }
    "password:" {
        send "$password\r"
    }
}
interact
expect eof


存为  test.exp

命令行中执行  expect test.exp

ok, over

posted @ 2018-04-15 18:59  lobtao  阅读(210)  评论(0编辑  收藏  举报