Last active
April 15, 2021 09:28
-
-
Save djleonskennedy/aa4a53265523d2bd805bb5cea7e40f48 to your computer and use it in GitHub Desktop.
connect to vpn via "openconnect" automatically with OTP
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/sh | |
PASSWORD=<userpassword> | |
BASE32_TOKEN=<BASE32 SECRET> | |
HOST=vpn.some.com | |
# topt token generation | |
# tools can be get here https://www.nongnu.org/oath-toolkit/ | |
# also don't forget to set current time | |
# this method is using is in case if "token" and "password" swapped | |
# with default topt config use this http://www.infradead.org/openconnect/token.html (no oathtool required) | |
TOKEN=`oathtool --base32 --totp $BASE32_TOKEN` | |
#user input sequence | |
sequence="${TOKEN}\n${PASSWORD}" | |
# CONFIG example | |
<< //// | |
user=<username> | |
authgroup=<group name> | |
passtos | |
os=win | |
//// | |
printf $sequence | openconnect --script /etc/vpnc/vpnc-script --config=CONFIG $HOST |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment