Skip to content

Instantly share code, notes, and snippets.

@daniepetrov
Last active July 4, 2023 15:35
Show Gist options
  • Save daniepetrov/44513c8846a1169b7a93f51767cc223a to your computer and use it in GitHub Desktop.
Save daniepetrov/44513c8846a1169b7a93f51767cc223a to your computer and use it in GitHub Desktop.
# add your vpn password to .vpn_password file
echo "mypassword > ~/.vpn_password
chmod 600 ~/.vpn_password
# add these lines to .zshrc or .zprofile
function vpn-up() {
local VPN_HOST="host"
local VPN_USER="username"
local SERVER_CERT="pin-sha256:87+Hf09J6X30/vKmSGLPA35scH/jey/aP7zL4sQ+5+i="
local VPN_AUTH_GROUP="authgroup"
if [ ! -f ~/.vpn_password ]; then
echo "Error: missing ~/.vpn_password"
return
fi
echo "Starting the vpn ..."
echo $(cat ~/.vpn_password) | sudo openconnect --background --passwd-on-stdin --user=$VPN_USER --servercert=$SERVER_CERT --authgroup=$VPN_AUTH_GROUP $VPN_HOST
}
function vpn-down() {
sudo kill -2 `pgrep openconnect`
echo "\n"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment