Configuring VPN using nmcli

I’m on Manjaro stable KDE edition. I have a few openvpn configurations ( .ovpn files). I’m able to setup VPN connections graphically using Settings → (Network) Connections → + → Import VPN connection. It copies some certificates to ~/.local/share/..., further, I can enter username and password in the detailed settings screen, and the password is stored encrypted.

How do I do exactly the same setup using CLI? This will help me automate my setup.

Importing ovpn file using nmcli works:

nmcli conn import type openvpn file <my-ovpn-file>

How do I add username and password to this connection, and ensure that the password is stored encrypted?

Found this toturial, more specifically:

  1. The contents of client.ovpn
    client
    nobind
    dev tun
    redirect-gateway def1
    remote 198.51.100.1 1194 udp
    comp-lzo yes
    auth-user-pass pass.txt
    auth-nocache

    — — -BEGIN CERTIFICATE — — -
    The contents of ca.crt that you generate on server
    — — -END CERTIFICATE — — -
  2. Create a pass.txt file at the same folder with client.ovpn with the content is username/password of VPN client, In this case, is test/test@1234

:bowing_man: