This project provides a small Bash script to manage OpenVPN connections with a simple menu or direct commands.
It supports starting, stopping, and checking the status of .ovpn profiles, including those stored in subfolders, and handles spaces in filenames.
The script stores runtime state and PID files in /run for clean process management.
- Interactive menu (start, stop, status)
- Non-interactive CLI usage (
vpn-menu start "Profile") - Supports spaces in profile filenames and directories
- Tracks runtime with PID and state files under
/run - Auto-elevates with
sudoif not run as root - Designed for one VPN connection at a time (safe and predictable)
- Clean installer and uninstaller scripts
- Linux
- OpenVPN installed and in your
PATH - Common tools:
bash,find,xargs,pgrep,sudo - Root privileges (script re-execs with
sudoautomatically)
Clone or download the repo and run:
./install-vpn-menu.shThis will install vpn-menu into /usr/local/bin.
To remove everything:
./uninstall-vpn-menu.shYou will be asked whether to delete PID/state and log files.
By default, the script looks for .ovpn files in:
~/VPNs/~/VPNs/
├── Try Hack Me/
│ └── Try Hack Me.ovpn
└── Hack The Box/
└── Hack The Box.ovpn
vpn-menuvpn-menu start # choose from list
vpn-menu start "Try Hack Me" # start specific profile (omit .ovpn)
vpn-menu stop
vpn-menu status
vpn-menu -h / --helpstart: prompts for a profile unless one is suppliedstop: stops the currently running OpenVPN instancestatus: shows the active profile and PID
The script writes temporary state to /run:
/run/openvpn-<slug>.pid— PID of the OpenVPN process/run/openvpn-<slug>.state— full path to the profile used
These are automatically removed when the VPN is stopped.
- No profiles listed: ensure
.ovpnfiles exist under$VPN_DIR - "Another OpenVPN is running": use
vpn-menu stopfirst - Permission errors: run with
sudo, or ensure you installed correctly unknownprofile shown: ensure.statefile was created correctly
This project is licensed under the MIT License.
You are free to use, modify, and distribute this software with proper attribution.