#!/bin/bash set -euo pipefail IFS=$'\n\t' if [[ $# -ne 2 ]]; then echo "Usage: $0 " 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 <> "$1" <