- Download ovpn config files from VPNUnlimited (contact: support@keepsolid.com)
- Extract zip file, remove email and UserID from file name. Filename should be
location.ovpn
. You can use rename tool like PyRenamer - Put all
ovpn
files toovpn_conf
- Put
nm_vpn_gen.py
andnm_conf.tpl
to directory containovpn_conf
directory - Run "python nm_vpn_gen.py".
Created
August 8, 2017 18:18
-
-
Save rooty/de7ef6da2204f31b29d79c8c13f86ba3 to your computer and use it in GitHub Desktop.
VPNUnlimited: create VPN config for Network Manager using ovpn files
This file contains 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
[connection] | |
id=VPNUnlimited $name | |
uuid=$uuid | |
type=vpn | |
permissions= | |
secondaries= | |
[vpn] | |
connection-type=tls | |
remote=$server.vpnunlimitedapp.com | |
comp-lzo=yes | |
reneg-seconds=0 | |
cert-pass-flags=0 | |
cert=$path/certs/client_$server.crt | |
dev=tun | |
key=$path/certs/client_$server.key | |
ca=$path/certs/ca.crt | |
service-type=org.freedesktop.NetworkManager.openvpn | |
[vpn-secrets] | |
no-secret=true | |
[ipv4] | |
dns=8.8.8.8;8.8.4.4; | |
dns-search= | |
ignore-auto-dns=true | |
method=auto | |
[ipv6] | |
dns-search= | |
ip6-privacy=0 | |
method=ignore |
This file contains 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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
""" Generate NetworkManager VPN config from VPNUnlimited ovpn files | |
""" | |
import re | |
import os | |
import glob | |
from string import Template | |
from uuid import uuid4 as random_uuid | |
nm_vpn_template = open("nm_conf.tpl", 'r') | |
tpl_src = Template(nm_vpn_template.read()) | |
vpn_conf_path = os.path.dirname(os.path.realpath(__file__)) | |
for directory in ["ovpn_conf", "certs", "nm_conf"]: | |
if not os.path.exists(directory): | |
os.makedirs(directory) | |
for fovpn in glob.glob("ovpn_conf/*.ovpn"): | |
with open(fovpn, 'r') as finput: | |
fbasename = os.path.basename(finput.name).split('.')[0] | |
certs = re.search(r'<cert>\n(.*?)</cert>\n<key>\n(.*?)</key>', | |
finput.read(), | |
re.DOTALL) | |
client_crt, client_key = certs.groups() | |
fclient_crt = open("certs/client_%s.crt" % fbasename, 'w+') | |
fclient_crt.write("{}".format(client_crt)) | |
fclient_crt.close() | |
fclient_key = open("certs/client_%s.key" % fbasename, 'w+') | |
fclient_key.write("{}".format(client_key)) | |
fclient_key.close() | |
data = {'name': fbasename.upper(), | |
'uuid': random_uuid(), | |
'path': vpn_conf_path, | |
'server': fbasename} | |
fnmconf = open("nm_conf/VPNUnlimited%s" % data['name'], 'w+') | |
fnmconf.write(tpl_src.substitute(data)) | |
fnmconf.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment