Client Setup
After setup.sh runs on the server, ./scripts/setupclient.sh and ./scripts/setupclient.ps1 are ready to distribute. The scripts are idempotent: if a WireGuard config already exists on the client, they bring up the existing tunnel and exit.
What Happens
- The script generates a WireGuard X25519 keypair locally — the private key never leaves the device.
- It sends only the public key plus
X-Auth-Tokentohttps://<SERVER>/addnewpeer. - The server responds with a WireGuard config containing
<PASTE_YOUR_PRIVATE_KEY_HERE>. - The script substitutes the placeholder with the locally-generated private key.
- The config is written to disk and the tunnel is started.
Linux
Prerequisites
sudo apt install wireguard-tools curl python3On RHEL/Fedora:
sudo dnf install wireguard-tools curl python3Run
chmod +x setupclient.sh
sudo ./setupclient.shWhat It Does
- Checks that
wg,curl, andpython3are in PATH; requires root. - If
/etc/wireguard/wg0.confalready exists → runswg-quick up wg0and exits. - Generates keypair:
wg genkey→ private key;echo privkey | wg pubkey→ public key. - Registers with the server:
curl -sk -X POST \ -H "Content-Type: application/json" \ -H "X-Auth-Token: <token>" \ -d '{"public_key": "<pubkey>"}' \ https://<SERVER_IP>/addnewpeer - Parses the JSON response with
python3. Validatesstatus == "ok". - Replaces
<PASTE_YOUR_PRIVATE_KEY_HERE>with the private key → writes/etc/wireguard/wg0.conf(mode 600). - Runs
wg-quick up wg0and enablessystemctl enable wg-quick@wg0.
Generated Config Structure
[Interface]
PrivateKey = <client-private-key>
Address = 10.13.26.X/32
DNS = 172.29.144.30
[Peer]
PublicKey = <server-public-key>
Endpoint = <SERVER_IP>:51820
AllowedIPs = 0.0.0.0/0
PersistentKeepalive = 25AllowedIPs = 0.0.0.0/0 routes all traffic through the VPN. DNS queries go to Pi-hole at 172.29.144.30.
Manage the Tunnel
sudo wg show wg0
sudo wg-quick down wg0
sudo wg-quick up wg0Adding More Clients
Run the setup script on any new device. Each run generates a fresh keypair and allocates the next available IP. No server action is required. The pool supports 253 peers (10.13.26.2 through 10.13.26.254).
Manual Peer Removal
There is no automated deregistration. To remove a peer:
rm ./peers/<sha256-prefix>.conf
docker exec wireguard wg set wg0 peer <public-key> remove