Skip to content

Instantly share code, notes, and snippets.

@InFog
Last active August 7, 2025 13:38
Show Gist options
  • Save InFog/f73f974d42d59882733fd5f44469933d to your computer and use it in GitHub Desktop.
Save InFog/f73f974d42d59882733fd5f44469933d to your computer and use it in GitHub Desktop.

Revisions

  1. InFog revised this gist Aug 7, 2025. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions rc.sh
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,10 @@
    # Remember to first import the config into openvpn3. Change the $CONFIG_NAME into name that makes sense to you
    # openvpn3 config-import --config profile.ovpn --name $CONFIG_NAME

    # Replace
    # Add the code below to your shell's .rc file. Replace the strings below with the proper values.
    # - $CONFIG_NAME
    # - EMAIL_ADDRESS
    # - BASE64_ENCODED_PASSWORD
    # - BASE64_ENCODED_PASSWORD - To avoid exposing your password

    vpn-off () {
    openvpn3 session-manage --config $CONFIG_NAME --disconnect 2> /dev/null
  2. InFog revised this gist Aug 7, 2025. 1 changed file with 8 additions and 0 deletions.
    8 changes: 8 additions & 0 deletions rc.sh
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,11 @@
    # Remember to first import the config into openvpn3. Change the $CONFIG_NAME into name that makes sense to you
    # openvpn3 config-import --config profile.ovpn --name $CONFIG_NAME

    # Replace
    # - $CONFIG_NAME
    # - EMAIL_ADDRESS
    # - BASE64_ENCODED_PASSWORD

    vpn-off () {
    openvpn3 session-manage --config $CONFIG_NAME --disconnect 2> /dev/null
    printf "Disconnected from VPN.\n"
  3. InFog created this gist Aug 7, 2025.
    24 changes: 24 additions & 0 deletions rc.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    vpn-off () {
    openvpn3 session-manage --config $CONFIG_NAME --disconnect 2> /dev/null
    printf "Disconnected from VPN.\n"
    }

    vpn-on () {
    if [ -z "$1" ];
    then
    echo "Usage: vpn-on <2FA code>\n";
    else
    vpn-off
    printf "Connecting to VPN.\n"
    printf "EMAIL_ADDRESS\n$(echo "BASE64_ENCODED_PASSWORD==" | base64 --decode)\n$1" | openvpn3 session-start --config $CONFIG_NAME
    printf "Connected to VPN.\n"
    fi
    }

    vpn-status () {
    if [ -z "$(openvpn3 sessions-list | grep "Client connected")" ]; then
    printf "VPN is disconnected.\n";
    else
    printf "VPN is connected.\n";
    fi
    }