Autoconnect VPN not working in Network Manager

Take away id from nmcli con up.

If you want to fully automate it, try the following:

nmcli con up $(nmcli con show | grep -m1 vpn | awk '{print $1}')

This will pick the first available vpn and connect to it.

If you want to connect to it automatically on vm startup, do the following in your sys-vpn (or dvm template, if sys-vpn is disposable):

  1. Create the script and make it executable:
$ cat <<EOF > $HOME/start_vpn.sh
#!/bin/bash
nmcli con up \$(nmcli con show | grep -m1 vpn | awk '{print \$1}')
EOF
$ chmod +x $HOME/start_vpn.sh
  1. Create autostart file
$ mkdir -p $HOME/.config/autostart
$ cat <<EOF > $HOME/.config/autostart/start_vpn.desktop
[Desktop Entry]
Type=Application
Name=Start VPN
Exec=$HOME/start_vpn.sh
EOF

This should do it.