Skip to content

Instantly share code, notes, and snippets.

@danpetrv
Last active July 4, 2023 15:35
Show Gist options
  • Select an option

  • Save danpetrv/44513c8846a1169b7a93f51767cc223a to your computer and use it in GitHub Desktop.

Select an option

Save danpetrv/44513c8846a1169b7a93f51767cc223a to your computer and use it in GitHub Desktop.

Revisions

  1. danpetrv revised this gist Jul 4, 2023. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions openconnect_other
    Original file line number Diff line number Diff line change
    @@ -5,10 +5,10 @@ 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:<cert>"
    local VPN_AUTH_GROUP="<authgroup>"
    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"
  2. danpetrv created this gist Jul 4, 2023.
    24 changes: 24 additions & 0 deletions openconnect_other
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@

    # 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:<cert>"
    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"
    }