- 先要安装python的包管理器pip,用brew或者apt-get均可。
- Python 2 用
sudo pip install onetimepass
,Python 3 用sudo -H pip3 install onetimepass
- 需要okta绑定 google authenticator 时 QR code里面的16位的 secret, android 用 barcode scaner 一扫就知道了
- 填到 auth.py 里
- 填用户名密码到 inputs.txt
- 以后每次运行
./vpn connect
(用 zsh or fish,bash需要改动vpn文件的第一行) 就登上了 ./vpn diconnect
下线
-
-
Save howiehu/10045c041c9f889f5460 to your computer and use it in GitHub Desktop.
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
import onetimepass as otp | |
my_secret = 'SECRET_FROM_QRCODE' | |
print(otp.get_totp(my_secret)) |
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
USENAME | |
PASSWORD | |
3 | |
AUTHENTICATOR_CODE | |
exit |
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
#!/bin/zsh | |
answers=$(sed 's/AUTHENTICATOR_CODE/'$(python auth.py)'/g' inputs.txt) | |
echo $answers | /opt/cisco/anyconnect/bin/vpn -s $1 xdc.vpn.thoughtworks.com |
vpn脚本第三行加上 << EOF | sed 's/Password: .*/Password: ********/g'
变为
echo $answers | /opt/cisco/anyconnect/bin/vpn -s $1 xdc.vpn.thoughtworks.com << EOF | sed 's/Password: .*/Password: ********/g'
这样可以隐藏密码,根据XI QI的第三版的启发
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Works like charm. Thanks!
ps.
inputs.txt
的第三行应为 Google Authenticator 认证在你自己的认证方式中的排序,不一定是3