Ubuntu – OpenVPN connect on startup

openvpnUbuntu

I'm using OpenVPN on Ubuntu 12.04 LTS. I've set up OpenVPN to connect to my vpn service. It works great. Now, I need it to connect automatically.

I can run from a terminal

nmcli con up uuid 334464e5-5d0d-40f3-a4db-d41ca7e2929d

and it works great.

I'd like to make it connect when the system starts. I added that command as a startup program, but still doesn't connect.

I edited /etc/default/openvpn as well. I added this line:

AUTOSTART="VYPRVPN"

Still no joy.

From the logs:

Jan  2 23:11:19 ubuntu12-virtual-machine NetworkManager[1023]: <info> VPN service 'openvpn' started (org.freedesktop.NetworkManager.openvpn), PID 2241
Jan  2 23:11:19 ubuntu12-virtual-machine NetworkManager[1023]: <info> VPN service 'openvpn' appeared; activating connections
Jan  2 23:11:19 ubuntu12-virtual-machine NetworkManager[1023]: <error> [1388725879.294774] [nm-vpn-connection.c:934] get_secrets_cb(): Failed to request VPN secrets #2: (6) No agents were available for this request.
Jan  2 23:11:24 ubuntu12-virtual-machine NetworkManager[1023]: <info> VPN service 'openvpn' disappeared

VPN Secrets? Help?

Best Answer

When you set up your VPN connection through the GUI the password is saved in the key-ring. If you save your password in the connection file, like this:

sudo nano /etc/NetworkManager/system-connections/MyConnectionExampleName

in this file:

    # 1 here means key-ring I  think, but with 0, the password below is  used
    password-flags=0 

    [vpn-secrets]
    password=my_secret_password