Skip to content

Instantly share code, notes, and snippets.

@howiehu
Forked from jcouyang/README.md
Last active May 14, 2019 04:12
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save howiehu/10045c041c9f889f5460 to your computer and use it in GitHub Desktop.
Save howiehu/10045c041c9f889f5460 to your computer and use it in GitHub Desktop.
  1. 先要安装python的包管理器pip,用brew或者apt-get均可。
  2. Python 2 用 sudo pip install onetimepass,Python 3 用 sudo -H pip3 install onetimepass
  3. 需要okta绑定 google authenticator 时 QR code里面的16位的 secret, android 用 barcode scaner 一扫就知道了
  4. 填到 auth.py 里
  5. 填用户名密码到 inputs.txt
  6. 以后每次运行 ./vpn connect (用 zsh or fish,bash需要改动vpn文件的第一行) 就登上了
  7. ./vpn diconnect 下线
import onetimepass as otp
my_secret = 'SECRET_FROM_QRCODE'
print(otp.get_totp(my_secret))
USENAME
PASSWORD
3
AUTHENTICATOR_CODE
exit
#!/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
@richardzone
Copy link

Works like charm. Thanks!

ps. inputs.txt 的第三行应为 Google Authenticator 认证在你自己的认证方式中的排序,不一定是3

@fanksid
Copy link

fanksid commented Jan 7, 2017

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