From 0c62efd4455363ea15f867755bb369ec2698e3ce Mon Sep 17 00:00:00 2001 From: Patrick Wagner Date: Fri, 3 Oct 2025 15:57:02 +0200 Subject: [PATCH] Add create_wg_config.sh --- create_wg_config.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 create_wg_config.sh diff --git a/create_wg_config.sh b/create_wg_config.sh new file mode 100644 index 0000000..2e9b4f5 --- /dev/null +++ b/create_wg_config.sh @@ -0,0 +1,34 @@ +#!/bin/tcsh -f +echo -n "Enter a name for the wireguard config: " +set name = $< +echo -n "Enter the IP for this wireguard config: " +set ip = $< +echo -n "Enter the endpoint for this wireguard config: " +set endpoint = $< +echo -n "Enter the endpoint port for this wireguard config: " +set port = $< +echo -n "I will create a config with name $name and IP $ip. Is this correct? (y/n): " +set correct = $< +if ($correct == "y" || $correct == "Y") then +set wg_pubkey = `wg | grep public | cut -d " " -f5` +set conffile = "$name"_client.conf +set serverconf = "$name"_server.conf +set private = `wg genkey | tee "$name"_private.key` +set public = `wg pubkey < "$name"_private.key | tee "$name"_public.key` +set psk = `wg genpsk | tee "$name"_preshared.key` +# Client config file +echo "[Interface]" > $conffile +echo "PrivateKey = $private" >> $conffile +echo "Address = $ip/24" >> $conffile +echo "DNS = 31.182.126.198" >> $conffile +echo "" >> $conffile +echo "[Peer]" >> $conffile +echo "PublicKey = $wg_pubkey" >> $conffile +echo "PresharedKey = $psk" >> $conffile +echo "AllowedIPs = 0.0.0.0/0" >> $conffile +echo "Endpoint = ${endpoint}:${port}" >> $conffile +# Server config file +echo "[Peer]" > $serverconf +echo "AllowedIPs = $ip/32" >> $serverconf +echo "PreSharedKey = $psk" >> $serverconf +echo "Publickey = $public" >> $serverconf