Created
July 6, 2020 01:35
-
-
Save pengzhendong/7316ba0e60fafb53f50101d841de6b28 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/expect | |
trap { | |
set XZ [stty rows] | |
set YZ [stty columns] | |
stty rows $XZ columns $YZ < $spawn_out(slave, name) | |
} WINCH | |
set timeout 2 | |
set HOST [lindex $argv 0] | |
set USER <Your Google Authenticator username> | |
set KEY <Your Google Authenticator key> | |
spawn ssh -t $USER@<JumpServer name> ssh $HOST | |
expect "Verification code: " { | |
set CODE [exec oathtool --totp -b -d 6 $KEY] | |
send "$CODE\r" | |
} | |
expect "<Username>@<Server name>" { | |
send "cd $USER; exec /bin/bash --rcfile .bashrc\r" | |
} | |
interact |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment