Last active
August 7, 2025 13:38
-
-
Save InFog/f73f974d42d59882733fd5f44469933d to your computer and use it in GitHub Desktop.
OpenVPN management
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
| # 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 | |
| # 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 - To avoid exposing your password | |
| 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 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment