Created
April 13, 2015 11:02
-
-
Save fireyy/e43229954e709bf0277e to your computer and use it in GitHub Desktop.
两步验证跳板机自动登录,依赖安装 oathtool
This file contains 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 -f | |
set timeout 30 | |
set secret YOUR_SECRET | |
set username YOUR_NAME | |
set password YOUR_PASSWORD | |
set host YOUR_HOST | |
log_user 0 | |
spawn oathtool --totp --base32 $secret | |
expect -re \\d+ | |
set otp $expect_out(0,string) | |
spawn ssh -2 $username@$host | |
expect "Verification code:" | |
send "$otp\n" | |
expect "Password:" | |
send "$password\n" | |
interact |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment