iterm 跳板机配置
2018-03-09 本文已影响26人
simler
解决Mac中ssh自动登录的问题, 写一个expect脚本实现自动登陆跳转Jumper
- SSH连接
ssh -i key/xxx.pem xxx@10.0.5.20 - 修改权限
sudo chmod 600 key/xxx.pem
SSH自动连接脚本
- 脚本一
#!/usr/bin/expect
if { $argc != 1 } {
send "Usage: Opt or ID\n"
exit
}
set ID [lindex $argv 0]
set TERMSERV 10.0.5.20
set USER xxx
set PASSWORD 123456
catch { spawn ssh -i /Users/woody/key/xxx.pem $USER@$TERMSERV }
expect "*xxx.pem*" { send "$PASSWORD\r" }
expect "*Opt or ID**" { send "$ID\r"; interact }
expect /Users/woody/key/ssh_login_sq.expect 1
- 脚本二
#!/usr/bin/expect
set ID [lindex $argv 0]
set TERMSERV 10.0.5.20
set USER xxx
set PASSWORD 123456
catch { spawn ssh -i /Users/xxx/key/xxx.pem $USER@$TERMSERV }
expect "*xxx.pem*" { send "$PASSWORD\r" }
expect "*Opt or ID**" { send "$ID\r"; interact }
expect /Users/woody/key/ssh_login_sq.expect
jumper-2.jpeg