WireGuard Server Setup Tutorial
This tutorial shows how to set up a WireGuard server on a VPS with xyz.sh/wireguard and connect clients.
$ curl -fsSL xyz.sh/wireguard | bash
Details · xyz.sh/wireguard · Last updated:
Prerequisites
A KVM (full virtualisation) VPS with a 5.6+ kernel or the distro's WireGuard module, and root.
Allow UDP 51820 (or your chosen port) in the security group.
Follow local law and your provider's terms.
Steps
Optional: read the source with curl -fsSL xyz.sh/wireguard.sh and compare xyz.sh/wireguard.sh.sha256.
Install and create the first client: curl -fsSL xyz.sh/wireguard | bash -s -- -y
On a phone, install the WireGuard app and scan the QR code; on a computer import /etc/wireguard/clients/client1.conf.
Add clients: curl -fsSL xyz.sh/wireguard | bash -s -- --add-client laptop -y
Custom port, hostname or DNS: --port 51820 --endpoint vpn.example.com --dns 1.1.1.1
How to verify
Run wg show to see the interface and peer handshakes; latest handshake updates once a client connects. Or curl -fsSL xyz.sh/wireguard | bash -s -- --status.
How to undo or uninstall
curl -fsSL xyz.sh/wireguard | bash -s -- --uninstall -y stops wg-quick@wg0 and removes the xyz.sh-generated configs in /etc/wireguard and 99-xyz-wireguard.conf; the wireguard-tools package is kept.