Created
February 17, 2020 08:36
-
-
Save joltcan/6091e39268568aef2acf36b941dd1600 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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