Issue
The command-line interface (CLI) for OpenVPN Connect doesn't currently support direct connect or disconnect commands on macOS or Windows. This is confirmed by their absence in the CLI help output (--help).
References:
Workaround
You can work around this limitation by using the target extension commands, which allow connection and disconnection through a saved profile using the profile ID:
--connect-shortcut=<ovpn_profile_ID>--disconnect-shortcut=<ovpn_profile_ID>
Note: This workaround launches OpenVPN Connect's graphical user interface (GUI) and may not be suitable for headless or automated environments.
Step-by-step instructions
- Open the terminal and navigate to the OpenVPN Connect app path:
On WindowsC:\Program Files\OpenVPN Connect\OpenVPNConnect.exe
On macOS/Applications/OpenVPN Connect.app/Contents/MacOS - List available profiles and retrieve the profile_ID of the OpenVPN profile:
On Windows./OpenVPNConnect.exe --list-profiles
On macOS./OpenVPN\ Connect --list-profiles)
Copy the output of the"id"value to the clipboard. - Run the
--connect-shortcutcommand to connect using the profile ID:
On Windows./OpenVPNConnect.exe --connect-shortcut=<ovpn_profile_ID>
On macOS./OpenVPN\ Connect --connect-shortcut=<ovpn_profile_ID>
*(replace<ovpn_profile_ID>with the value copied to clipboard) - Connection has been established.
- In order to disconnect from the VPN run
--disconnect-shortcut
On Windows./OpenVPNConnect.exe --disconnect-shortcut
On macOS./OpenVPN\ Connect --disconnect-shortcut
Important Note
This method doesn't provide a true CLI experience:
- It triggers the GUI, making it unsuitable for automation or scripts.
- There's no silent or headless mode equivalent available at this time.
We're aware of this limitation, and full CLI connect/disconnect support may be introduced in a future release.
Comments
0 comments
Please sign in to leave a comment.