Browse Source

Add presharedkeys to new peers

pull/1/head
Julien Escario 4 years ago
parent
commit
d7eb0da8b7
  1. 5
      wireguard/deploy-wg-clients.sh

5
wireguard/deploy-wg-clients.sh

@ -6,7 +6,7 @@
# IP=x bash <(curl -s https://gitlab.altinea.fr/altinea/install-scripts/raw/branch/master/wireguard/deploy-wg-clients.sh) # IP=x bash <(curl -s https://gitlab.altinea.fr/altinea/install-scripts/raw/branch/master/wireguard/deploy-wg-clients.sh)
if ! [[ $IP =~ ^[0-9]{1,3}$ ]] ; then if ! [[ $IP =~ ^[0-9]{1,3}$ ]] ; then
echo "error: Please set IP variable (with IP=1-254. See https://phpipam.altinea.fr" >&2; exit 1
echo "error: Please set IP variable (with IP=1-254. See https://ipam.as41405.net" >&2; exit 1
fi fi
if ! modprobe -q wireguard ; then if ! modprobe -q wireguard ; then
@ -17,6 +17,7 @@ fi
# Create keys subdir, generate private and derive public key # Create keys subdir, generate private and derive public key
mkdir -p /etc/wireguard/keys mkdir -p /etc/wireguard/keys
umask 077 && wg genkey > /etc/wireguard/keys/private.key && wg pubkey < /etc/wireguard/keys/private.key > /etc/wireguard/keys/public.key && umask 0022 umask 077 && wg genkey > /etc/wireguard/keys/private.key && wg pubkey < /etc/wireguard/keys/private.key > /etc/wireguard/keys/public.key && umask 0022
PRESHAREDKEY=`wg genpsk`
# Calculate IPv4 and IPv6 address # Calculate IPv4 and IPv6 address
IP4="10.17.25.$IP" IP4="10.17.25.$IP"
@ -32,6 +33,7 @@ PostUp = ping -c1 10.17.25.1
[Peer] [Peer]
PublicKey = iu3I09FtiVDIOuiU83JvpfJkg4yiCxolqcFsXbz5Ixc= PublicKey = iu3I09FtiVDIOuiU83JvpfJkg4yiCxolqcFsXbz5Ixc=
PresharedKey = $PRESHAREDKEY
AllowedIPs = 10.17.24.0/22, fd42:42:42::/48 # All Wireguard address space AllowedIPs = 10.17.24.0/22, fd42:42:42::/48 # All Wireguard address space
AllowedIPs = 172.16.5.0/24, fc00:db8:f00:bebe::/64 # OpenVPN Admin tunnel AllowedIPs = 172.16.5.0/24, fc00:db8:f00:bebe::/64 # OpenVPN Admin tunnel
@ -45,6 +47,7 @@ echo "[Peer]"
echo "# "`hostname -f` echo "# "`hostname -f`
echo -n "PublicKey = " echo -n "PublicKey = "
cat /etc/wireguard/keys/public.key cat /etc/wireguard/keys/public.key
echo "PresharedKey = $PRESHAREDKEY"
echo "AllowedIPs = $IP4/32, $IP6/64" echo "AllowedIPs = $IP4/32, $IP6/64"
read -n1 -r -p "Press space only AFTER configuration is done ..." read -n1 -r -p "Press space only AFTER configuration is done ..."

Loading…
Cancel
Save