Last active
January 19, 2021 14:03
-
-
Save i-v-s/3246ab426c9816bb91ebaf1459f61ba2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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/sh | |
# Usage: sh wg.sh number endpoint:35053 public_key | |
sudo apt update | |
sudo apt install -y openresolv wireguard | |
umask 077 | |
wg genkey > privatekey | |
pk=`cat privatekey` | |
sudo cat > /etc/wireguard/wg0.conf << EOL | |
[Interface] | |
Address = 10.8.0.$1/24 | |
PrivateKey = ${pk} | |
DNS = 8.8.8.8 | |
[Peer] | |
PublicKey = $3 | |
Endpoint = $2 | |
AllowedIPs = 10.8.0.1/24 | |
PersistentKeepalive = 20 | |
EOL | |
wg pubkey < privatekey | |
rm privatekey | |
sudo systemctl start wg-quick@wg0 | |
sudo systemctl enable wg-quick@wg0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment