Linux通过expect配置自动登录
2017-07-25 00:00
633 查看
在
expect登陆脚本
expect配置脚本
在
home目录下创建
.expect目录,并添加两个文件:
expect登陆脚本
ssh-login.exp
#!/usr/bin/expect -f set timeout 30 set host [lindex $argv 0] set port [lindex $argv 1] set user [lindex $argv 2] set password [lindex $argv 3] spawn ssh -p $port $user@$host expect { "yes/no" { send "yes\r"; exp_continue } "password:" { send "$password\r" } } interact
expect配置脚本
ssh-login.sh
# alias ssh-name="./expect/ssh-login.exp host port username password" alias ssh-n1.cluster=".expect/ssh-login.exp 192.168.9.181 22 root cluster" alias ssh-n2.cluster=".expect/ssh-login.exp 192.168.9.182 22 root cluster" alias ssh-n3.cluster=".expect/ssh-login.exp 192.168.9.183 22 root cluster" alias ssh-n4.cluster=".expect/ssh-login.exp 192.168.9.184 22 root cluster" alias ssh-n5.cluster=".expect/ssh-login.exp 192.168.9.185 22 root cluster"
在
.bashrc下添加
if [ -f ~/.expect/ssh-login.sh ]; then . ~/.expect/ssh-login.sh fi
相关文章推荐
- 通过expect自动登录到30台linux机器运行相同命令
- linux expect 自动登录交换机保存配置
- 在linux下如何通过expect正确执行自动切换登录,并且执行命令和脚本
- iTerm2 结合 Linux expect 实现 ssh 自动登陆, 通过跳板机登录服务器内网功能
- Linux 通过 expect 实现 tenlnet 自动登录
- 用了一天的时间,linux下expect实现ssh自动登录服务器记,鄙视下网上各种抄来抄去残段子
- Linux下通过EXPECT脚本自动执行ssh远程连接
- Mac OS下配置远程Linux 服务器SSH密钥认证自动登录
- linux expect远程自动登录以及执行命令
- linux expect自动登录ssh,ftp
- linux expect自动登录s…
- linux expect详解(ssh自动登录)
- linux expect自动登录ssh,ftp
- shell脚本通过expect实现自动单边无密登录功能
- Mac OS X下配置远程Linux 服务器SSH密钥认证自动登录
- linux中使用expect实现自动登录
- Linux使用expect脚本实现远程机器自动登录
- Linux配置SSH公钥认证与Jenkins远程登录进行自动发布
- linux expect, spawn自动登录
- Mac OS X下配置远程Linux 服务器SSH密钥认证自动登录