Openconnect keeps asking for username in Ubuntu 20.04

I found a solution by modifying manually the vpn configuration file in the /etc/NetworkManager/system-connections/ folder.

  1. First close any active VPN connection,
  2. Open with root privilege the file corresponding your VPN settings in the /etc/NetworkManager/system-connections/ folder,
  3. Then find the vpn-secrets section and add your credentials
    [vpn-secrets]
    form:main:group_list=FOO
    form:main:[email protected]
    lasthost=vpn.bar.net
    save_passwords=yes
  1. Save, close and reboot

Enjoy your automatic VPN login..


For some reason I could not get this to work by editing the file. However the workaround by Etienne CHAMPETIER, from https://bugzilla.redhat.com/show_bug.cgi?id=1332491#c24 works:

nmcli con mod VPNNAME vpn.secrets 'form:main:group_list=GROUPNAME','form:main:username=USERNAME','save_passwords=yes'

I had to setup group_list, username and save_passwords.