diff options
author | uvok cheetah | 2024-05-27 19:08:23 +0200 |
---|---|---|
committer | uvok cheetah | 2024-05-27 19:08:23 +0200 |
commit | cf3cd322192a2f21c4d6b141c5820e9d1619a848 (patch) | |
tree | 179f6057e997a25ba143fdaea039a7bbe257661a /scripts/wireguard-new-peer.sh | |
parent | 4e5fee8fa1a64a8f03253d3976090de305281067 (diff) |
Add new wireguard helper scripts
Diffstat (limited to 'scripts/wireguard-new-peer.sh')
-rw-r--r-- | scripts/wireguard-new-peer.sh | 43 |
1 files changed, 0 insertions, 43 deletions
diff --git a/scripts/wireguard-new-peer.sh b/scripts/wireguard-new-peer.sh deleted file mode 100644 index 28ca90e..0000000 --- a/scripts/wireguard-new-peer.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash - -set -euo pipefail -IFS=$'\n\t' - -if [[ $# -ne 2 ]]; then - echo "Usage: $0 <wg server config file> <desired ip for client (without CIDR)>" - exit 1 -fi - -# create client keypair -cli_privkey=$(wg genkey) -cli_pubkey=$(wg pubkey <<< "$cli_privkey") - -# PrivateKey = ... -# if you don't leave a space, this won't work -#srv_pubkey=$(awk -e '/PrivateKey/ { print $2; }' "$1" | wg pubkey) -srv_pubkey=$(awk -e 'match($0, /^PrivateKey\s*=\s*(.*)$/, ar) { print ar[1]; }' "$1" | wg pubkey) -srv_port=$(awk -e 'match($0, /^ListenPort\s*=\s*(.*)$/, ar) { print ar[1]; }' "$1") - -# create client config -echo "*** Scan this with your mobile phone ***" -qrencode -t ansiutf8 <<EOF -[Interface] -PrivateKey = $cli_privkey -Address = $2/24 - -[Peer] -PublicKey = $srv_pubkey -Endpoint = $(hostname --fqdn):${srv_port} -AllowedIPs = 0.0.0.0/0, ::/0 -PersistentKeepalive = 30 -EOF - -cat >> "$1" <<EOF - -# Auto-Generated -[Peer] -PublicKey = $cli_pubkey -AllowedIPs = $2/32 - -EOF - |