How to get NetworkManager/OpenVPN to connect automatically?
I'd like my VPN connection to always connect by default, so I don't manually have to toggle it every time I reboot or wake from suspend.
I'm using GNOME / NetworkManager / OpenVPN
I installed PIA VPN connections with their install script, everything works fine aside from having to manually toggle it on all the time
I did find this forum post where it looks like someone else had the same issue, and it seems the solution was to create a systemd service for the connection
So then I found this Wiki article, however I don't seem to have any .conf files anywhere
The PIA install script put all the connections under /etc/NetworkManager/system-connections
I tried checking /etc/openvpn/client/client.conf but client.conf doesn't exist on my system.
The solution that firecat53 describes in the forum post doesn't seem to work either, plus I don't want to have to tell every single WiFi connection to use the VPN, I just want it to always use the VPN by default, if possible. And actually, the "Automatically connect to VPN when using this connection" doesn't even exist anymore, there is no "General" tab as he's describing. The post is from 2014 so I don't think it's accurate anymore.
Can someone point me in the right direction here?
Edited 28 Nov 2018. We only hold this version.
About this post
- Posted
- Archived
- Edited
- Score
- 24 · 100% up
- Kind
- Text
- ID
- a1bd4e
11 comments
Open
nm-connection-editorand select your preferred VPN connection then click the settings/gear button. Enter the VPN password and click the icon inside the password box and select "Store the password for all users" then save the changes. Now select your wifi network and click the settings icon. Go to the General tab, tick "Automatically connect to VPN" and select the vpn connection and Save.Ah I didn't realize that
nm-connection-editorwas a separate utility, I was just checking GNOME Settings.Well I found this setting, and it "technically"works, but it just causes my connection to fail over and over after I wake from sleep
sounds like you didn't store the password for all users...
Damn so it was storing for all users to disable asking password.. also didn't know it was by that path to do "Automatically connect to VPN".
I guess there are no easy ways for terminal way for doing this.
OpenVPN will probably look for files by default in
/etc/openvpn/client. PIA will give you files with some other extention, like ovpn or something. Just change them all toconf; or just the one that you're interested in. Put the other files (from PIA) in that location and add a file with your username on one line and password on the other. I think openvpn looks for a file calledauthfor this info.
As for startup, you'll need a file /usr/lib/systemd/system/openvpn-client@.service which I tthink gets installed along with openvpn. You'll have to enable it using
systemctl enable openvpn-client@US_West, after which it should start up automatically and connect. Replace US_West with whatever name of conf file you want, but leave off the .conf.
This glosses over some details but I think you'll get set up quickly with this info.
Are you using an applet for Network Manager?
If so, right click nm-applet > Edit Connections
Edit your Ethernet or Wifi Connection > General Tab
Tick 'Automatically connect to VPN', choose default VPN connection
Click Save
yeah I could only get the General tab to appear if I ran
nm-connection-editor, wasn't showing up in the GNOME settings/appletDeleted before we saved it.