Import OpenVPN Config From Command Line with Network Manager

By | 2017/01/14

Network Manager on Linux has a command line interface which can do everything and more than the gui version. Here is how to import an openvpn config from the command line!

In this example, the openvpn config is a single file from pfSense (Inline Configurations > Other, in pfSense speak) which works well for Linux users.

Import as follows, where the filename in this example is is: bach-udp-1194-khmiller-config.ovpn

$ sudo nmcli connection import type openvpn file bach-udp-1194-khmiller-config.ovpn
Connection 'bach-udp-1194-khmiller-config' (5b04c610-ca37-4f76-bb61-07e9acdc603a) successfully added.


nmcli does have tab completion, so when in doubt hit tab as options are typed to see what is possible.


$ sudo nmcli [TAB]
agent       connection  device      general     help        monitor     networking  radio       
$ sudo nmcli connection [TAB]
add      clone    delete   down     edit     export   help     import   load     modify   monitor  reload   show     up       
$ sudo nmcli connection edit [TAB]


6 thoughts on “Import OpenVPN Config From Command Line with Network Manager

  1. Utux

    You can import .ovpn files from the GUI. But sometimes it’s bugged, for example in Debian Jessie. Thanks for the CLI tip 🙂

  2. Nebojša

    I cannot import split.ovpn.

    sudo nmcli connection import type openvpn filesplit.ovpn
    [sudo] password for nebojsa:
    Usage: nmcli connection { COMMAND | help }

    COMMAND := { show | up | down | add | modify | edit | delete | reload | load }

    show [–active] [[id | uuid | path | apath] ] …

    up [[id | uuid | path] ] [ifname ] [ap ]

    down [id | uuid | path | apath]


    modify [–temporary] [id | uuid | path] ([+|-]. )+

    edit [id | uuid | path]
    edit [type ] [con-name ]

    delete [id | uuid | path]


    load [ … ]

    1. Nebojša

      Error: ‘import’ is not valid ‘connection’ command.

  3. Maki

    This gives me an error on Debian 9:
    Error: failed to load VPN plugin: cannot load legacy-only VPN plugin “openvpn” for “/etc/NetworkManager/VPN/”.

    Am I missing something here?

  4. c. mosers

    I guess you could bat file in and use the vpn data as $1


Leave a Reply

Your email address will not be published. Required fields are marked *

Notify me of followup comments via e-mail. You can also subscribe without commenting.