Ubuntu – Automatically Connect to VPN on Boot (Without Keyring Prompt)

This post assumes that you have set up a VPN connection on Ubuntu already that you are able to use, and will show you how to make that connection start on boot.

First, the easy step; tell your existing connection to automatically connect to the VPN:

  1. Open up “Network Connections”
  2. Highlight your default network connection
  3. Click edit
  4. Choose the “General” tab
  5. Check the box “Automatically connect to VPN when using this connection” and choose your VPN connection
  6. Save


Stop the Keyring Prompt

At this point, if you restart your machine, you’ll be prompted to enter your keyring:


To make this go away on boot, navigate to /etc/NetworkManager/system-connections and look for a file named after your VPN connection.  For me, it was “pia-toronto(openvpn)”.  In this file, make two changes:

  1. Under the “[vpn]” section, remove the “password-flags=1” line.
  2. Add a new section, “[vpn-secrets]” to the file with your VPN account password underneath it:

And now you should be good to go.

3 thoughts on “Ubuntu – Automatically Connect to VPN on Boot (Without Keyring Prompt)

  1. Kevin W.

    This isn’t working for me. I’m fairly new to linux. I”m using Ubuntu 16.04. Using ipvanish vpn, which uses an ovpn file to configure the vpn.

    I can set up the vpn fine and connect, and set the wired connection to automatically use the vpn connection. When I boot, it doesn’t connect to the network at all.

    I tried editing the file for networkmanager, but it seemed to remove the network connection when I did. I had to recreate it, and that made a new file. Any help/suggestions?


Leave a Reply

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