Ubuntu – Automatically connect an Openconnect VPN connection

network-managernetworkingopenconnectpasswordvpn

I installed the network-manager-openconnect package and uses it to login to my Openconnect VPN server. The connection works, except that every time I start the connection a two step dialog box pops up and asks for my VPN username and password:

enter image description here

This is the first dialog which asks for the username. If the username is correct, it'll go to the second dialog and ask for the password.

Is there a way to provide the VPN username and password in a configuration file so that it doesn't ask for it every time? This is important since I'm trying to make this machine headless.

Or alternatively is there a way to have network-manager-openconnect get the username and password from the keyring, and have the keyring be automatically unlocked after login? I'm using Ubuntu 16.04 LTS Beta 2.

Best Answer

Does openconnect work for you?

If so you can use this to connect automatically:

sudo openconnect SERVER --no-cert-check -u USERNAME --passwd-on-stdin  <PASS_FILE

or

echo PASS | sudo openconnect SERVER --no-cert-check -u USERNAME --passwd-on-stdin