Adding VPN Connection by Importing OpenVPN config file

Forum rules
Before you post please read how to get help
Post Reply
badchorizo
Level 1
Level 1
Posts: 5
Joined: Sat Oct 11, 2014 11:56 pm

Adding VPN Connection by Importing OpenVPN config file

Post by badchorizo » Mon Mar 16, 2015 7:03 pm

Setup: Fresh install of 17.1 KDE, everything working smoothly.

Is it possible to add a new VPN connection in Network Manager by importing an OpenVPN config file (commonly provided by VPN service providers) rather than by manually typing in all of the information found in the config file? I was previously using Mint 16, 17 and 17.1 Cinnamon and in Gnome there was an "Import" button along with the manual "Add" button, but there is not an import button I can find in KDE Network Manager, or in nmcli as far as I can tell.

Example config file:

Code: Select all

client
dev tun
proto tcp
remote nyc-a01.ipvanish.com 443
resolv-retry infinite
nobind
persist-key
persist-tun
persist-remote-ip
ca ca.ipvanish.com.crt
tls-remote nyc-a01.ipvanish.com
auth-user-pass
comp-lzo
verb 3
auth SHA256
cipher AES-256-CBC
keysize 256
tls-cipher DHE-RSA-AES256-SHA:DHE-DSS-AES256-SHA:AES256-SHA
I googled, and found lots of references to this for several different distros not just Mint, but no solutions. Some threads talk about the import function being broken since 2010, others say there is no import function. So, I'm confused. In the interest of keeping the topic focused:

1.) Is there a way to add a new OpenVPN connection by importing a config file such as the one above?

2.) If there is no way to import, is there any other way (e.g. a bash script) to facilitate adding a large number of new connections? Or should I just bite the bullet and type everything manually?

cartland
Level 1
Level 1
Posts: 11
Joined: Thu Nov 29, 2012 10:06 pm

Re: Adding VPN Connection by Importing OpenVPN config file

Post by cartland » Tue Mar 17, 2015 1:34 am

I would certainly hope so as I intend to upgrade. At the moment I'm using Mint 13 KDE. It does have an import button in the VPN tab of the Network Manager.
VPNImport.jpeg
.

badchorizo
Level 1
Level 1
Posts: 5
Joined: Sat Oct 11, 2014 11:56 pm

Re: Adding VPN Connection by Importing OpenVPN config file

Post by badchorizo » Fri Mar 20, 2015 4:38 pm

I feel like I must be missing something obvious, but I'll be damned if I can find it anywhere. Here is what Network Management Settings in 17.1 looks like side by side with the image you posted:
kdenetman.jpg
The window you posted is exactly what I was trying to find, but it seems to have been removed from Network Manager, whether mistakenly or intentionally. To make matters worse, I am having trouble even manually entering the OpenVPN config settings in the "Add Connection" dialogue, because there is no uniform standard of what the different options are called, so I don't know which text goes in which box and trial and error is not working yet :(

cartland
Level 1
Level 1
Posts: 11
Joined: Thu Nov 29, 2012 10:06 pm

Re: Adding VPN Connection by Importing OpenVPN config file

Post by cartland » Fri Mar 27, 2015 9:34 pm

(just updated my profile to get notified of replies).

I've setup a mint 17.1 machine at work. I'll have a look at it on Monday and see if I can find anything because I need this as well.

cheers

User avatar
Cobber
Level 3
Level 3
Posts: 193
Joined: Wed Feb 26, 2014 5:15 am
Location: Australia

Re: Adding VPN Connection by Importing OpenVPN config file

Post by Cobber » Tue Apr 14, 2015 2:06 pm

I have just installed a VPN on my KDE Mint 17 box. It took quite a lot of searching to find out how to do it and what settings to use.

To create a new VPN connection, left click on the Network icon in your taskbar (the one just before the notification triangle). In the box that opens up, click on the spanner icon. That will open the Connection Editor.

To import your .ovpn file, click on File>Import VPN

This will preload the data from your VPN provider. That file is a text file and can be opened with Kate. Depending on what requirements your VPN company requires, you may need to copy the code between some of the tags to paste into new files. Mine required a ca.cert file to be made. So you just copy the code between the <ca> and </ca> tags and create the new file with Kate. You then edit your new VPN connection while still in the Connection Editor and tell it where you put that file.

Those were all the steps I needed to do for my provider, apart from inputting my username and password, and it connected successfully.

There are two more files you can create if needed. The certificate.crt file uses the data between the <cert> and </cert> tags. The key.key file uses the <key> and </key> tags. I did not need to create those two files.

In most of the boxes that pop up when you edit your VPN connection, simply accept the default settings. I think the only change I made was to allow connection for all users.

Now when you click on the Network icon, you will see your new VPN connection and you simply click on "Connect" and a padlock will be added to your tray.

Hope this helps. If you need more info just let me know and I will see if I can help.
PC: Dual HDD: Mint 18.2 64-Bit KDE / Windows7 Professional
HP Dv7 Laptop Dual HDD: MX Linux / Windows 7 Home
Lenovo x230 Laptop Dual boot: Mint 18.1 64-Bit KDE / Windows7 Professional

mintqui
Level 1
Level 1
Posts: 2
Joined: Thu Apr 26, 2012 1:41 am

Re: Adding VPN Connection by Importing OpenVPN config file

Post by mintqui » Sun Jun 21, 2015 10:01 pm

wow, so this is *STILL* broken? I used to import openVPN connections, it broke a long time ago, I move to my Mac, It's been ?? 5 years and I thought it would surely be fixed by now ... still not? wow.

User avatar
krumm
Level 1
Level 1
Posts: 14
Joined: Thu Feb 12, 2015 11:42 am
Location: East Coast

Re: Adding VPN Connection by Importing OpenVPN config file

Post by krumm » Tue Jun 30, 2015 6:34 pm

On Cinnamon at least, there is an import option, but it's in the Settings -> Networking
Click the + to add a new network, choose VPN, then select Import from file.

User avatar
krumm
Level 1
Level 1
Posts: 14
Joined: Thu Feb 12, 2015 11:42 am
Location: East Coast

Re: Adding VPN Connection by Importing OpenVPN config file

Post by krumm » Sat Jul 04, 2015 11:45 am

krumm wrote:On Cinnamon at least, there is an import option, but it's in the Settings -> Networking
Click the + to add a new network, choose VPN, then select Import from file.
Actually, it's even easier then that.

Open Network Connections and click the ADD button.
From the Choose A Connection Type dialog, select "Import a saved VPN configuration" and click Create.
Browse to the config file and click Open.

That's pretty much it.

It even populates the certificate fields if the saved config contains them and is formatted properly. If you have a .ovpn file, it should work for you.

mintqui
Level 1
Level 1
Posts: 2
Joined: Thu Apr 26, 2012 1:41 am

Re: Adding VPN Connection by Importing OpenVPN config file

Post by mintqui » Sat Jul 04, 2015 2:03 pm

It doesn't work for me...

-----------------------------------
xxxxx@lmde-32-cin:~$ inxi -S
System: Host: lmde-32-cin Kernel: 3.11-2-486 i686 (32 bit) Desktop: Cinnamon 2.0.14 Distro: LinuxMint 1 debian

--------------------------
I have these installed:
openvpn
network-manager-openvpn-gnome
network-manager-openvpn



--------------------------------------------------------------
I go to Menu >> Preferences >> Network Connections

I click 'Add'

I select "import a saved VPN connection" >> Create

I locate the client.ovpn file and click 'open'

and the window just disappears. I'm back to blank desktop.

If I go back into Network Connections, there is no VPN added.




---
It seems like the importer doesn't like something and it's crashing the Network Connection app. Why doesn't it work for me? Any ideas? I tried a second .ovpn from a different VPN and got the same behaviour. And I tried both of these ovpn files on Shimo VPN client (Mac) and they both imported fine.

User avatar
krumm
Level 1
Level 1
Posts: 14
Joined: Thu Feb 12, 2015 11:42 am
Location: East Coast

Re: Adding VPN Connection by Importing OpenVPN config file

Post by krumm » Wed Jul 08, 2015 12:13 am

mintqui wrote:It doesn't work for me...
It seems like the importer doesn't like something and it's crashing the Network Connection app. Why doesn't it work for me? Any ideas? I tried a second .ovpn from a different VPN and got the same behaviour. And I tried both of these ovpn files on Shimo VPN client (Mac) and they both imported fine.
I'm not familiar with Shimo, but I can import a Viscosity config from a mac - the equivalent file is Viscosity.conf.

I put the ovpn file and the cert files into a folder in my ~/home/VPN/sitename folder. Contents of .ovpn look like this:

dev tun
persist-tun
persist-key
cipher AES-256-CBC
auth SHA1
tls-client
client
resolv-retry infinite
remote 10.10.1.2 1194 udp
lport 0
verify-x509-name "YourUsername" name
auth-user-pass
pkcs12 fw-udp-1194.p12
tls-auth fw-udp-1194-tls.key 1
comp-lzo adaptive
ca ca.crt
tls-auth ta.key 1
cert cert.crt
key key.key

badchorizo
Level 1
Level 1
Posts: 5
Joined: Sat Oct 11, 2014 11:56 pm

Re: Adding VPN Connection by Importing OpenVPN config file

Post by badchorizo » Sun Jul 19, 2015 5:41 am

I saw that 17.2 for KDE was released and then I remembered posting this topic. Has anyone who upgraded to 17.2 already checked to see if there is a way to import OpenVPN config files using the GUI, basically exactly the same way it is done in Gnome (unless it changed since Mint 17)?

I ended up working around this by using the openvpn cli to connect to VPN, and then making scripts. I'm not on my Mint computer at the moment, but I created a generic script for connecting to one vpn server and automatically inputting my credentials. Of course, all the config files for different cities/servers are the same except for the lines with the server address, so I set out to do the simple task of figuring out how to automatically take my generic script and output one new script for every config file provided. LOL. I do not know if regular expressions was the best way to do this, but it's what I bashed my against my head until one randomly worked. I came across the joke "now you have two problems" while Googling for help, so that was worth it. :)

I think (hope, pray) I made a note of what cli utility I finally used to do this and what commands, because I honestly can't remember already :( But it's not on this computer in any case... While I'm thinking about it, do any people who DO know what they are doing have suggestions for what the most efficient way to generate these scripts would be? Whatever I settled on was ugly and I'm sure would horrify programmers, but it did ultimately work after hours of trial and error. Was this a job for regular expressions or was that needlessly masochistic?

ANYWAY, this is still a lame solution because I have to open a directory with my scripts and then run one. I would prefer to click network icon in taskbar, get a popup list of connections, click, done.

Oh yeah, if you use openvpn cli to connect to vpn, you'll get errors if not run as superuser. so either sudo or run script elevated.

badchorizo
Level 1
Level 1
Posts: 5
Joined: Sat Oct 11, 2014 11:56 pm

Re: Adding VPN Connection by Importing OpenVPN config file

Post by badchorizo » Sun Jul 19, 2015 5:50 am

Cobber wrote:I have just installed a VPN on my KDE Mint 17 box. It took quite a lot of searching to find out how to do it and what settings to use.

To create a new VPN connection, left click on the Network icon in your taskbar (the one just before the notification triangle). In the box that opens up, click on the spanner icon. That will open the Connection Editor.

To import your .ovpn file, click on File>Import VPN

This will preload the data from your VPN provider. That file is a text file and can be opened with Kate. Depending on what requirements your VPN company requires, you may need to copy the code between some of the tags to paste into new files. Mine required a ca.cert file to be made. So you just copy the code between the <ca> and </ca> tags and create the new file with Kate. You then edit your new VPN connection while still in the Connection Editor and tell it where you put that file.

Those were all the steps I needed to do for my provider, apart from inputting my username and password, and it connected successfully.

There are two more files you can create if needed. The certificate.crt file uses the data between the <cert> and </cert> tags. The key.key file uses the <key> and </key> tags. I did not need to create those two files.

In most of the boxes that pop up when you edit your VPN connection, simply accept the default settings. I think the only change I made was to allow connection for all users.

Now when you click on the Network icon, you will see your new VPN connection and you simply click on "Connect" and a padlock will be added to your tray.

Hope this helps. If you need more info just let me know and I will see if I can help.
Unless I'm not understanding, you describe what I consider "manually" creating each connection - a process that takes a few minutes for each one. I'm looking for a way to do this "automatically" where it looks to the config file for every single piece of information it needs other than login/password. For example, either (1) import a config file with ONLY a few clicks, like in Gnome (or even in OpenVPN for Windows for crying out loud!) so that the GUI network manager shows the new openvpn connection as an option when you click on taskbar icon, or (2) import many config files (e.g. one for every server your provider provides) to network manager all in one step (a little typing or some cli is fine here, since it is doing it for every single one you have).

Baxtex
Level 1
Level 1
Posts: 3
Joined: Sat Jul 26, 2014 11:23 am

Re: Adding VPN Connection by Importing OpenVPN config file

Post by Baxtex » Thu Jul 30, 2015 8:34 am

I having trouble with this aswell. I'm on 17.2 but I can't seem to import my vpn's config file. I click the netwrok icon>VPN>Configure>add>Import from file then I find my config file and add it but I keep getting an error saying "The file ovpn.conf could not be read or doesn't contain any information about vpn-connections error:Unknown error"

I have opend it to check of course and it does contain al the info that is nedded, anything I could try?

Mihesuah
Level 1
Level 1
Posts: 1
Joined: Sat Aug 08, 2015 8:28 pm

Re: Adding VPN Connection by Importing OpenVPN config file

Post by Mihesuah » Sat Aug 08, 2015 8:33 pm

I have no problem setting up OpenVPN for Mate. Here are my steps that I wrote down for my use. Yes, it is a manual step, but it's amazing how we will use all the time in the world to automate something.

Steps to create a VPN using Private Internet Access.

1. OPen a terminal
2. type in "sudo apt-get install network-manager-openvpn network-manager network-manager-gnome network-manager-openvpn-gnome" and select <Enter>.
3. Enter in password and select <Enter> to complete install.
4. If asked to install something, select "y" to complete the installation.
5. type in "mkdir OpenVPN-setup-PIA" and select <Enter>.
6. Change to the new directory by typing in "cd OpenVPN-setup-PIA" and selecting <Enter>.
7. Now obtain a list of gateways by typing in "sudo wget https://www.privateinternetaccess.com/o ... penvpn.zip" then selecting <Enter>.
8. Enter in password and select <Enter> to complete the download.
9. type in "sudo unzip openvpn.zip" and select <Enter> to extract all the files.
10. type in "sudo cp ca.crt /etc/openvpn" and select <Enter> to copy the certificate over.
11. type in "sudo cp crl.pem /etc/openvpn" and select <Enter>.
12. Verify the files copied by typing "ls /etc/openvpn/ -altr" then select <Enter>.
13. Type "Exit" to leave terminal.
14. Left-click Ethernet Network Connection.
15. Select VPN Connections.
16. Select Configure-VPN.
17. Select Select Add.
18. When Choose a Connection Type is displayed, using the drop down menu look for and select "Import a saved VPN configuration...".
19. Select Create
20. Select Home > OpenVPN-setup-PIA > location.ovpn file
21. The file is open with the VPN tab open, enter your Username and Password associated with your account.
22. Save the file.
23. Left-click Ethernet Network Connection.
24. Select the VPN just setup.
25. Congrats you are now connected.
---------------------------------------------
To stop the browser from reporting that you are using a vpn.
---------------------------------------------
26. Open a browser and go to ipleak.net.
27. Open a tab and go to dnsleaktest.com
28. On the ipleak.net select WebRTC Leaks to bring up #webrtcleak.
29. Open a new tab "about:config".
30. Search for "media.peerconnection.enabled".
31. Change Value field from true to false.

viper37
Level 3
Level 3
Posts: 106
Joined: Wed Aug 15, 2012 10:04 am
Location: Quebec

Re: Adding VPN Connection by Importing OpenVPN config file

Post by viper37 » Wed Sep 09, 2015 1:00 pm

I'm gonna need some help.
Mint Cinnamon 17.2

I followed the instructions here:
https://my.privatoria.net/cp/vpn/#openvpn_linux_gui
OpenVPN is installed. Since it didn't work the first time, I downloaded a .deb file from OpenVPN.net, rebooted, but it is still the same result.

On step 3, I do not see an option for "OpenVPN". I have PPTP and "import a saved VPN configuration". When I point to my provider configuration file, I get an error message: "The file could not be read or does not contain recognized VPN connection information. Error: unknown error".

Here is the content of the configuration file:

Code: Select all

dev tun
proto udp
remote gateway-hk.privatoria.net 1194
cipher AES-128-CBC
auth SHA1
resolv-retry infinite
nobind
persist-key
persist-tun
client
verb 3
auth-user-pass

<ca>
-----BEGIN CERTIFICATE-----
[...]
-----END CERTIFICATE-----
</ca>
Linux Mint 18.1 Cinnamon
Intel Pentium G3240 3.1ghz dual-core
H81I-PLUS/CSM
256gb ADATA SSD (Ext4, OS drive)
WD Red 6TB (x2) (BTRFS, data drives)
16gb RAM

viper37
Level 3
Level 3
Posts: 106
Joined: Wed Aug 15, 2012 10:04 am
Location: Quebec

Re: Adding VPN Connection by Importing OpenVPN config file

Post by viper37 » Wed Sep 09, 2015 1:13 pm

Never mind, i got it working :)

The instructions given by my provider conveniently forgot this line:
sudo apt-get install openvpn bridge-utils
that did the trick.
Linux Mint 18.1 Cinnamon
Intel Pentium G3240 3.1ghz dual-core
H81I-PLUS/CSM
256gb ADATA SSD (Ext4, OS drive)
WD Red 6TB (x2) (BTRFS, data drives)
16gb RAM

Spotten
Level 1
Level 1
Posts: 1
Joined: Sun Apr 30, 2017 3:31 pm

Re: Adding VPN Connection by Importing OpenVPN config file

Post by Spotten » Sun Apr 30, 2017 6:31 pm

Sorry for OT! :mrgreen:

It's working for me, but it would be nice if it was possible to add more than one adress at the time, especially when you want to add 779 servers! :D

Is there some way to do this? Thanks.

Post Reply

Return to “KDE”