iterm 跳板机配置

解决Mac中ssh自动登录的问题, 写一个expect脚本实现自动登陆跳转Jumper

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

你可能感兴趣的:(iterm 跳板机配置)