I'm trying to setup OpenVPN using NetworkManager. The GUI seems buggy and unresponsive. Are there any other tools for setting up a VPN client?

up vote 123 down vote accepted

Yes, you can use OpenVPN directly. This way you can use more settings as well.

First you need the openvpn package:

sudo apt-get install openvpn

Then you can connect like this:

sudo openvpn --config /path/to/config.ovpn

The sudo is important because OpenVPN won't be able to connect otherwise (I think because it has to change the routes).

  • I cannot find the config.ovpn file – Yan King Yin Apr 17 '15 at 15:18
  • 2
    @YanKingYin You should get it from VPN service provider. – Ali Shakiba May 22 '15 at 8:48
  • 9
    To make it permanent, edit /etc/default/openvpn and uncomment the line AUTOSTART="all" and copy your ovpn file to /etc/openvpn/config.conf - must has .conf extension – Thales Ceolin Jun 25 '15 at 21:59
  • 2
    @YanKingYin you should be able to download it by logging to your vpn server from browser. – Aniket Thakur Jul 31 '15 at 18:21
  • and how would you stop the service cleanly, just killing the command ? – toine Dec 13 '16 at 21:02

Easiest method is running this command:

sudo apt-get install network-manager-openvpn-gnome

And then add a OpenVPN connection from Network Manager which after above command supports importing .ovpn files.

enter image description here

As Louis has explained installing openvpn client can be done with command

sudo apt-get install openvpn

However if you are using dual authentication mechanism for your vpn server, simple connection with

sudo openvpn --config /path/to/config.ovpn

will not be sufficient. You need some extra setup.

  1. Make sure your config file has auth-user-pass line.
  2. Next add --auth-retry interact to your connection command. So your entire command would look like

    sudo openvpn --config /path/to/config.ovpn --auth-retry interact
    
  • Doesn't cut it for me: SIGUSR1[soft,connection-reset] received, process restarting – Tomislav Nakic-Alfirevic Sep 18 at 10:26

I'm coming here from the locked How to setup VPN using an .ovpn file? [duplicate], because I wanted to give an answer to problems of importing *.ovpn files in the GUI, which some users experience.

Just like others, I've made sure to install:

$sudo apt-get install network-manager-openvpn-gnome

However, on Ubuntu 18.04 (had same problem on 16.04), I've not been able to import a *.ovpn file using the GUI (Settings -> Network -> VPN + -> 'Import from file'). I always get:

Cannot import VPN connection

The file "foo.ovpn" could not be read or does not contain recognized VPN connection information

Error: the plugin does not support import capabilities

However, I just stumbled upon the following instruction from nixCraft for importing a *.opvn file:

$ sudo nmcli connection import type openvpn file /path/to/foo.ovpn

After running that command, my VPN connection gets listed under 'Settings -> Network -> VPN'. After editing the password, my VPN connection works. The VPN connection is also listed in top-panel menu that shows connections, power, users among other things.

  • 1
    This capability also works in the gui nm-connection-editor. Run the program, click [+] and choose Import a saved VPN configuration. The gnome network settings interface for doing this is broken in 18.04, but the nm-connection-editor works nicely. – Steeve McCauley Oct 7 at 12:23

Install OpenVpn

sudo apt-get install network-manager-openvpn-gnome

Then go to Network Settings > Edit Connection > Add > Select VPN Point to Point Tunneling Protocol > Create

Add Username, Password and Gateway

Then go to Advanced Menu

Check Use point to point Encryption

Save

Then go to Network Settings > VPN Connection and select that VPN connection and connect it.

If you don't want to involve Network Manager, this git repository has a simple script that does the whole job very well using an interactive session with less than half-a dozen questions. See docs in download.

https://github.com/Nyr/openvpn-install.git

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.