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
自动登录脚本如下:
#! /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
相关文章推荐
- Linux中使用expect脚本实现远程机器自动登录
- shell中嵌套执行expect命令实例
- expect实现批量修改linux密码脚本分享
- expect实现单台、多台服务器批量scp传输文件
- shell结合expect写的批量scp脚本工具
- expect用法
- expect 打开文件
- expect
- Linux 远程执行命令,expect
- expect应用
- shell:expect实现非root用户切换脚本
- expect ssh ftp
- Expect 自动任务 集中部署
- expect 交互式脚本写法
- expect简单用法
- expect实现自动化模拟输入scp/ssh
- linux expect 用法
- CRemoteExec远程执行类
- linux用scp远程传输文件(自动化)
- linux 快捷登录三 expect脚本