55

Gnome network manager can't import any openvpn config file (.ovpn) after upgrading ubuntu to 16.04 version;

I get the following error message when I try to import openvpn config file:

The file 'file-x.ovpn' could not be read or does not contain recognized VPN connection information Error: the plugin does not support import capability
ahooee
  • 675

12 Answers12

38

The issue for me was the following line in my .ovpn file:

route remote_host 255.255.255.255 net_gateway

Commenting out this line allowed me to import the connection.

24

My setup

I also had the same issue, trying to import on an Ubuntu 16.04 client a .ovpn file produced by a home pritunl server.

The .ovpn file contained comment lines (#) as well as inline certificates (<ca>, <tls-auth>, <cert>, <key>). And there was no apparent reason to remove comments or keys. This same .ovpn had already been successfully imported into the Kubuntu 16.04 network manager, with only a warning about reneg-sec being too high; A clue to import issues on Ubuntu 16.04.

Solving the OP's errors

  1. The reneg-sec value is too high and encounters known import bug:

    reneg-sec 2592000
    

    Comment it out or use default value 3600.

    #reneg-sec 2592000
    

    This value can be re-set from Advanced settings in VPN config tab under:

    reneg-sec

  2. The config had two remote definitions:

    remote hostname.org 14195 udp6
    remote hostname.org 14195 udp
    remote-random
    

    Try with only one:

    #remote hostname.org 14195 udp6
    remote hostname.org 14195 udp
    #remote-random
    

After these two modifications, there were no import errors.

Further issue with remote configuration

Although there was no import error any more, the remote was not imported properly, i.e. the port and protocol were not properly parsed, so I had to further break the remote directive down in the .ovpn file as follows

    remote hostname.org
    port 14195
    proto udp

Summary

My .ovpn file contained comments as well as inline certificates, etc.. After reading some other posts, I thought the problem lied in the inline files or the comments, so I split the inline certificates and keys into separate files and removed all comments.

So in the end, after applying the above fixes, the .ovpn file with the inline keys and comments was imported.

Cas
  • 8,707
18

I also have Ubuntu 16.04, and the same problem occurs. The solution is not a very good solution, because you need another computer already connected with the VPN.

Check that you have already installed openvpn and network-manager, from the terminal:

$ sudo apt install openvpn network-manager-openvpn network-manager-openvpn-gnome
$ sudo systemctl restart network-manager

In general, this should work, but in very few cases (and i don't know why - i suppose that's probably a bug) a .ovpn can't be imported.

So, follow theses steps:

  1. On the computer that already have a created connection with the VPN, select the vpn connection

  2. make empty the password

  3. click on export button

At this point, you'd have a ".conf" file.

  1. open the ".conf" file and edit any parts that reference files on your computer if exists

  2. In your computer, create a new connection with the ".conf" file.

Cas
  • 8,707
João Paulo
  • 181
  • 1
  • 4
9

Try adding it through the terminal instead of through the GUI:

sudo nmcli connection import type openvpn file your-file.ovpn

As stated on https://bugs.launchpad.net/ubuntu/+source/network-manager-openvpn/+bug/606365

PS: You might still need to tweak your .ovpn with the tips found on other answers on this question nevertheless.

7
$ sudo openvpn --config file.ovpn

worked for me - I can tunnel, however I need to remember local IPs since I have no local DNS configured.

abukaj
  • 485
6

In my case it was necessary to remove all the comments (starting with #) from the *.ovpn. Some people found also that the line containing "remote SERVER NNNN" should be split into "remote SERVER" and "port NNNN".

Adam
  • 61
3

Edit *.ovpn file

Probably this is caused by settings in the .opvn file that can't be parsed.

First make sure you have the needed packages installed:

sudo apt update && sudo apt install network-manager-openvpn-gnome network-manager-openvpn openvpn

If it still fails, edit the *.ovpn file in a text editor and strip out the following lines that break the import.

<he> tag

If there is a <he> tag in the client ovpn config files, delete those lines. It's not needed:

<he>
...
</he>

Multiple connection details

If there is something like:

<connection>
remote <ip> 443 tcp-client
</connection
<connection>
remote <ip> 1194 udp
</connection>

Replace that section with this:

remote <ip> 1194 udp

The import stumbles upon multiple connections and doesn't support the <connection> tag. At least not in 16.04-17.04.

That's all, IMHO you can keep comments, they make no difference.

After you deleted the tag and edited the connection part, try to import the modified *.ovpn file. Solution from this blog post.

Janghou
  • 6,035
1

I had the same problem on a fresh Ubuntu 18.04 install. To my surprise openVPN was NOT installed by default.

I figured out because when I clicked "+" sign in "setting->Network->VPN"section the dialogue box did only had two option i.e. Open VPN option was not there.

I followed 1 and installed openvpn and restarted network manager everything worked fine after that as I can see the OpenVPN option on the popup image attached

sudo apt install openvpn network-manager-openvpn network-manager-openvpn-gnome
sudo systemctl restart network-manager

Joao Paulo's advice

mo-amit
  • 11
0

For me, I had to change the following in the .ovpn file:

remote ***.org 443 tcp-client

To:

proto tcp
remote ***.org 443

And also, as pointed by @Kostas Filios I had to change this part to a comment:

#reneg-sec 2592000
Shayan
  • 1,621
0

I had this problem while importing the .ovpn file with the network manager. I fixed it by changing my remote line from

remote vpn.example.com 1190 udp4

to

remote vpn.example.com 1190 udp

marcel.js
  • 101
0

I needed to replace the line remote xx.xx.xx.xx 443 tcp4 with remote xx.xx.xx.xx 443 tcp for it to work.

panta82
  • 469
0

All the tags should be removed. Tags like

<connection\>
</connection\>
<ca\>
</ca\>

Sometimes, the commenting doesn't work. Address the certificate to the file in which you store it.

 ca '/home/mersadkhan/.cert/nm-openvpn/su2-tcp-ca.pem'