expect ssh免交互远程

1.yum安装expect

yum -y install expect

2.数学shell脚本

#!/usr/bin/expect
spawn ssh root@192.168.245.158
expect {
        "(yes/no)?" {send 'yes\r';exp_continue}
        "password" {send "123456\r"}
}
expect "]#"
send "ifconfig\r"
send "exit\r"
expect eof

发布了7 篇原创文章 · 获赞 4 · 访问量 113

猜你喜欢

转载自blog.csdn.net/qq_47148037/article/details/105641745