Skip to content

Instantly share code, notes, and snippets.

@fireyy
Created April 13, 2015 11:02
Show Gist options
  • Save fireyy/e43229954e709bf0277e to your computer and use it in GitHub Desktop.
Save fireyy/e43229954e709bf0277e to your computer and use it in GitHub Desktop.
两步验证跳板机自动登录,依赖安装 oathtool
#!/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