I can't seem to get my openvpn connection to automatically connect when I wake up from system suspend or reboot. The openvpn connection works fine through the GUI, except there is no option to auto-connect. I've tried using nm-connection-editor, but after I check the box to auto-connect and save, the connection inexplicably fails. Adding secondaries to my wifi network through nmcli results in the same failure to connect. How can I auto-connect to my VPN through the GUI in Ubuntu 17.10? It seems like this is broken or something.

Update: So after selecting the auto-connect option from nm-connection-editor, then rebooting, I can manually reconnect to both interfaces successfully (the vpn service starts along with the network manager), but the system fails to connect automatically for some cryptic reason.


Wait wait wait. THIS worked. All you have to do is go

VPN->VPN Settings->connection_name->Identity->Password->"Store for all users"

and bingo problem solved.

If nm-connection-editor says that you can't save the connection (the save box is grayed out), then...just forget the network and set up the connection again (worked for me at least). Once you have checked said auto-connect box with nm-connection-editor and ensured that the VPN password is set to "Store for all users," both the primary connection AND the VPN will start successfully at the same time. Otherwise I keep getting this message in my syslog about

vpn-connection[...]: Failed to request VPN secrets #3: No agents were available for this request.

Literally just toggling that one option fixes the problem entirely. Use sudo service network-manager restart and it connects flawlessly the first time. To avoid the error loop on bootup specifically, just uncheck the box "Make available to other users" on the primary connection.

Also to prevent DNS leaks over your vpn when systemd-resolved is used, type

sudo nmcli connection modify <vpn-connection-name> ipv4.dns-priority -42

See the bug whose fix I personally backported to Ubuntu 17.04 at https://bugs.launchpad.net/network-manager/+bug/1624317

After restarting your network manager, you should check the output of systemd-resolve --status and make sure that ONLY the DNS servers of your VPN are listed. Use the 'Extended' test on the dnsleaktest site to confirm you aren't leaking DNS queries.

  • Thank you! With "store for all users" enabled, the VPN connection is established at system startup. But I discovered, that the entry with the password of the VPN, that is "stored for all users", vanished from Gnome's keyring (Seahorse). Do you know where the password is stored now? Is it encrypted at all? It has to be stored somewhere, since I don't have to enter it at startup. – DMT Dec 23 '17 at 12:46
  • It looks like users of Fedora 25 and 26 are having this exact same problem...and nobody's doing anything sigh Frankly, I'm not sure where the network manager would store the password other than the root-protected system-wide (hence available for all users) file with the connection ID name in /etc/NetworkManager/system-connections Check this link here for the same Fedora problem: bugzilla.redhat.com/show_bug.cgi?id=1389913 – Nicholas Stommel Dec 25 '17 at 20:40

Same here. It seems there is currently an open bug on ubuntu-manager package: https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/1718931

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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