John Albert Flores
John Albert Flores

Reputation: 132

Connecting to OpenVPN config using python

Is there any libraries for python that can be use for connecting to OpenVPN service using .ovpn configuration file?

The openvpn-api library needs OpenVPN installed on your system.

Upvotes: 1

Views: 4298

Answers (1)

Mikhail S
Mikhail S

Reputation: 188

Good news - you don't need any external libs to connect openvpn. You may just run cmd command from python script like this:

# write the command to a variable
cmd = 'start /b cmd /c "C:\Program Files\OpenVPN\bin\openvpn-gui.exe" --connect config.ovpn'
# split the command to parameters (It's not a necessity, it's just a rule of good taste)
args = shlex.split(cmd)
# run and remember the process as 'x'
x = subprocess.Popen(args, shell=True)

Upvotes: 1

Related Questions