Last active
April 3, 2025 02:17
-
-
Save theanht1/b155d13dc75a0ca6cb98e2ac0f5f36e8 to your computer and use it in GitHub Desktop.
Openconnect script as a cmd client to connect to Anyconnect VPN
This file contains hidden or 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 | |
| VPN_URL= | |
| VPN_GROUP= | |
| VPN_USER= | |
| VPN_PASSWORD= | |
| VPN_CERT_FILE= | |
| CERT_PASSPHRASE= | |
| # if [ $USER != "root" ] | |
| # then | |
| # echo "Must be run as root." | |
| # exit | |
| # fi | |
| # Prevent ctrl-c from killing the whole script | |
| trap '' 2 | |
| # Lauch openconnect | |
| # with user group | |
| # echo $VPN_PASSWORD | sudo openconnect $VPN_URL --user=$VPN_USER --usergroup=$VPN_GROUP --passwd-on-stdin | |
| # with cert file and passphrase | |
| echo $VPN_PASSWORD | sudo openconnect $VPN_URL --user=$VPN_USER --usergroup=$VPN_GROUP --certificate=$VPN_CERT_FILE --key-password=$CERT_PASSPHRASE --passwd-on-stdin | |
| # Stop trapping ctrl-c | |
| trap 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment