How to import many Wireguard VPN profiles with a basic script

Original forum link
https://forum.qubes-os.org/t/29166
Original poster
user111
Created at
2024-09-23 23:18:23
Last wiki edit
2024-09-28 19:12:34
Revisions
3 revisions
Posts count
6
Likes count
0

I created this very basic script to import and configure Wireguard VPN profiles on Debian. Save it to the same folder as your vpn.conf files. In debian it must be run as root. It will import the profile, set it to not autoconnect, and disconnect it. I will next work on one that will modify the VM's firewall rules, unless someone already has one or can do it quickly. I have no idea when I'll be able to start/finish it.

Script Import-WG-Profiles.sh

#!/bin/bash
#For Debian.
#Save in the same folder as the vpn.conf files and run from a root terminal.
for file in *.conf; do
c="${file%.*}"
sudo nmcli connection import type wireguard file $file && sudo nmcli connection modify $c autoconnect no && sudo nmcli con down $c
done

Edit: All characters are presenting correctly now.