#!/bin/bash # Ensure the script is run as root if [ "$EUID" -ne 0 ]; then echo "Please run as root" exit 1 fi # Install WireGuard apt update && apt install -y wireguard # Configure IP forwarding cat >/etc/sysctl.d/20-ip-forwarding.conf < /etc/wireguard/wg0.key echo "${public_key}" > /etc/wireguard/wg0.pub # Create server configuration file cat >/etc/wireguard/wg0.conf <