mac 无密码登录远程服务器
记录贴 使用expect 脚本 快速通过跳板机连接远程服务器
新建脚本 login.exp
示例如下:
#!/usr/bin/expect
#定义数组
#连接枚举
set connection_enum(1) "179"
set connection_enum(2) "gpu线上机器)"
set connection_enum(3) "ocr开发)"
set connection_enum(4) "ocr线上)"
#用户枚举
set connection_user(1) "seven"
set connection_user(2) "ubuntu"
set connection_user(3) "ubuntu"
set connection_user(4) "ubuntu"
#连接密码
set connection_passwd(1) "xxxxx"
set connection_passwd(2) "xxxx"
set connection_passwd(3) "xxxxxx"
set connection_passwd(4) "xxxxxxxxx"
#连接ip
set connection_ip(1) "10.10.0.0"
set connection_ip(2) "0.0.0.1"
set connection_ip(3) "127.0.0.1"
set connection_ip(4) "127.0.0.2"
#函数定义必须在使用前面否则会报错
#列出可用的host以及枚举
proc connectionlist {} {
global connection_enum
#[array size connection_enum]命令是求数组connection_enum的长度
for {set i 1}