美文网首页
ssh自动登录脚本

ssh自动登录脚本

作者: 咕咕鷄 | 来源:发表于2017-06-07 15:44 被阅读0次
#! /usr/bin/expect

set IP [lindex $argv 0]
set PWD [lindex $argv 1]

spawn ssh root@$IP
expect {
    "*(yes/no)?*" {
        send "yes\r"
        expect "*password:*"
        send "$PWD\r"
    } 
    "*password:*" {
        send "$PWD\r"
    }
}
interact 

存储上述代码为auto_ssh.sh,

chmod  +x auto_ssh.sh

使用方法

./auto_ssh.sh ip password

相关文章

网友评论

      本文标题:ssh自动登录脚本

      本文链接:https://www.haomeiwen.com/subject/fifafxtx.html