Skip to content

Instantly share code, notes, and snippets.

@joltcan
Created February 17, 2020 08:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joltcan/6091e39268568aef2acf36b941dd1600 to your computer and use it in GitHub Desktop.
Save joltcan/6091e39268568aef2acf36b941dd1600 to your computer and use it in GitHub Desktop.
#!/bin/bash
INTERFACE="wg0"
WGDIR=/etc/wireguard
WGCONF="$WGDIR/$INTERFACE.conf"
WGPORT="51820"
cd $WGDIR
if [ -f "$WGDIR/wg_private.key" ]
then
echo "keys exists, exiting"
exit 1
fi
umask 027
wg genkey > $WGDIR/wg_private.key
cat $WGDIR/wg_private.key | wg pubkey > $WGDIR/wg_public.key
PRIVKEY=$(cat $WGDIR/wg_private.key)
PUBKEY=$(cat $WGDIR/wg_public.key)
cat > $WGCONF << EOF
[Interface]
ListenPort = $LISTENPORT
PrivateKey = $PRIVKEY
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment