How to import WireGuard profile using nmcli on Linux
Importing WireGuard profile
Suppose I have a wireguard connection profile file:
[Interface]
PrivateKey = {private-key-here}
Address = 10.8.1.2/24
DNS = 10.8.1.1
[Peer]
PublicKey = {Pub-key-here}
PresharedKey = {Pre-shared-key-here}
AllowedIPs = 0.0.0.0/0
Endpoint = $Linux_SERVER_IP_HERE:$Port
It can be import into network manager with command:
$ nmcli connection import type wireguard file "/path/to/wg0.conf"
Then I can connect/disconnect the VPN using tray applet.
Autoconnect can be modified with command
$ nmcli connection modify home-vpn connection.autoconnect no