How to configure a new NetworkManager connection from a shell script/command line?
I've tried to find a way to configure a new connection manageable by NetworkManager using a terminal/shell script all day long, but I've been unsuccessful.
The reason is that I have a lot of openvpn configuration files and I wanted to have a nice and fast way of importing them, also beacuse NetworkManager openvpn plugin doesn't parse the certificates embedded into configuration files, so the only way to configure a new VPN connection is to do that manually via the GUI after I run a script to extract the certificates from the config files, which is a rather long and tedious process.
I found that on RedHat the nmcli utility has the ability to configure a new connection in this way:
nmcli con add [...]
However this is not possibile on (standard) Linux Mint 17.1.
I tried to add a new connection manually, adding a new file in /etc/NetworkManager/system-connections
[connection]
id=VPNConnection
id=3389cf54-949e-4c69-a746-864f0f8720b8
type=vpn
[vpn]
service-type=org.freedesktop.NetworkManager.openvpn
fragment-size=1300
connection-type=password-tls
password-flags=1
auth=MD5
tunnel-mtu=1500
cipher=AES-256-CBC
comp-lzo=yes
cert-pass-flags=0
remote=[vpn provider]
port=[vpn port]
mssfix=yes
username=[username]
remote-cert-tls=server
cert=[user cert]
ca=[ca cert]
key=[user priv. key]
[ipv6]
method=ignore
[ipv4]
method=auto
but this new configuration doesn't show up in NetworkManager.
Also, I don't have any ~/.gconf/system directory, neither under my personal home nor under /root.
Where could NetworkManager read configuration files from?
Solution 1:
Check your /etc/NetworkManager/NetworkManager.conf
Under [main]
there should be a plugins
directive and if you have enabled the keyfile
plugin (i.e. plugins=keyfile,ifupdown
or similar), it should monitor the /etc/NetworkManager/system-connections/
directory for file changes.
Further, a man NetworkManager.conf
tells you that 'it will ignore files that are readable or writeable by any user or group other than root'.
Don't know if this solves your problem, but it is worth checking out!
According to this, it should work with NetworkManager v7+
Cheers! / Daniel
Solution 2:
This worked for me:
nmcli reload "your connection name"
followed by a reboot. Reactivation will probably work as well.