Skip to content

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.

24 points10 comments
Open on Reddit
About this post
Posted
Archived
Edited
Score
24 · 100% up
Kind
Text
ID
a1bd4e

11 comments

Open nm-connection-editor and 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.

15 points

Ah I didn't realize that nm-connection-editor was a separate utility, I was just checking GNOME Settings.

6 points

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

4 points

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.

1 points

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 to conf; 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 called auth for 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.

4 points

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

3 points

yeah I could only get the General tab to appear if I ran nm-connection-editor, wasn't showing up in the GNOME settings/applet

1 points
unknown author

Deleted before we saved it.

1 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.