ssh 交互脚本

1.ssh交互

#!/bin/bash
passwd='123'
usradd="172.168.74.138"
/usr/bin/expect <<EOF
        spawn ssh root@$usradd
        expect {
                "yes/no" { send "yes\r";exp_continue }
                "password:" { send "$passwd\r" }
        }
        expect "]#"
                send "ifconfig\r"
                send "exit\r"
        expect eof

EOF  
posted @ 2019-12-23 15:18  Databasess  阅读(330)  评论(0)    收藏  举报