Pastebin
Paste #23715: No description
< previous paste - next paste>
Pasted by Anonymous Coward
cd /etc/wireguard umask 077 wg genkey | tee server.key | wg pubkey > server.pub config_file="/etc/wireguard/wg0.conf" cat > "$config_file" <<EOD [Interface] Address = 10.100.0.1/24, fd08:4711::1/64 ListenPort = 47111 EOD echo "PrivateKey = $(cat server.key)" >> "$config_file" ### Add clients: mkdir -p /etc/wireguard/client-config function add_client() { cd /etc/wireguard name="$1" wg genkey | tee "client-config/${name}.key" | wg pubkey > "${name}.pub" wg genpsk > "${name}.psk" cp "${name}.psk" "client-config" echo "[Peer]" >> /etc/wireguard/wg0.conf echo "PublicKey = $(cat "${name}.pub")" >> /etc/wireguard/wg0.conf echo "PresharedKey = $(cat "${name}.psk")" >> /etc/wireguard/wg0.conf echo "AllowedIPs = 10.100.0.$2/32, fd08:4711::$2/128" >> /etc/wireguard/wg0.conf cd - cd /etc/wireguard/client-config echo "[Interface]" > "${name}.conf" echo "Address = 10.100.0.$2/32, fd08:4711::$2/128" >> "${name}.conf" echo "DNS = 10.100.0.1" >> "${name}.conf" echo "PrivateKey = $(cat "${name}.key")" >> "${name}.conf" echo >> "${name}.conf" <<EOF [Peer] AllowedIPs = 10.100.0.1/32, fd08:4711::1/128 Endpoint = [your public IP or domain]:47111 PersistentKeepalive = 25 EOF echo "PublicKey = $(cat ../server.pub)" >> "${name}.conf" echo "PresharedKey = $(cat "${name}.psk")" >> "${name}.conf" qrencode -t ansiutf8 < "${name}.conf" qrencode -t png -o "${name}.conf.png" < "${name}.conf" cd - } add_client "myclient" "2"
New Paste
Go to most recent paste.