Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

One can import .ovpn files to NetworkManager through GUI tool nm-connection-editor (right click on nm-applet and click on Edit connections): Add -> Import a saved VPN configuration....

My goal is to do same thing but via command line using tools like nm-cli. Is it possible somehow?

share|improve this question
Did you make any progress with this? I am trying to do the same thing so will post an answer if I get it working. – David Mason Oct 13 '14 at 7:57
@DavidMason, unfortunately, no. I'm waiting for your solution. – petRUShka Oct 13 '14 at 12:11
I'm looking actively for for a solution too. – Raspbeguy Sep 18 '15 at 14:01

A workaround I use to get past the lack of functionality that comes with nmcli on debian-based systems is to use commands to copy an existing VPN config file in the /etc/NetworkManager/system-settings folder to a new file (as root, of course) in the same folder and make string replacements to the permitted user, gateway, username and password values in the new copy. Then I restart network manager to apply the changes.

For example:

A typical config file in /etc/NetworkManager/system-settings folder might look as such:





... so you can just create a new config file that looks similar to the one above...

cd /etc/NetworkManager/system-settings
cp "existing-working-vpn-config-file" "new-vpn-config-file"

...then replace the '<<>>' values above with your own VPN settings, eg:

sed -i "s/<<permissions_user>>/my_permissions_user/g" new-vpn-config-file
sed -i "s/<<user>>/my_user/g" new-vpn-config-file
sed -i "s/<<gateway>>/my_gateway/g" new-vpn-config-file
sed -i "s/<<password>>/my_password/g" new-vpn-config-file

... and then finally restart network manager via the following command:

service network-manager restart

Note: The UUID setting doesn't seem to matter, even if it's non-unique. No idea why. Stuff just works.

Also, If you are adding a new file rather than copying, make sure the permissions to the file are set to 600 (read and write), and the owner is root.

Give it a shot and tell me what you think. It works for me, all via command line.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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