iterm 跳板机配置

2018-03-09  本文已影响26人  simler

解决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
上一篇下一篇

猜你喜欢

热点阅读