您的位置:首页 > 运维架构 > Shell

shell实现自动登录服务器

2016-07-04 11:40 495 查看
yum install expect*
自动登录脚本如下:
#! /usr/bin/expect -f
set timeout 3
spawn ssh -p 22 root@111.111.111.111
expect {
"*yes/no" {send "yes\r";exp_continue}
}
expect "*password:"
send "123456789@#\r"

expect "root@*" {send "ls /opt\r"}
expect "root@*" {send "exit\r"}
interact
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  expect