From b1ccce7f23b48a23390b0c3f62f6f7597a871095 Mon Sep 17 00:00:00 2001 From: Ayush Mukherjee Date: Mon, 27 May 2024 14:09:41 +0530 Subject: [PATCH] chore: init repo --- createwg.sh | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 createwg.sh diff --git a/createwg.sh b/createwg.sh new file mode 100644 index 0000000..e364108 --- /dev/null +++ b/createwg.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +# enable ip forward +echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf +sysctl -p + +# install wireguard, wireguard-tools and curl +sudo apt-get update && sudo apt-get install -y wireguard wireguard-tools curl + +conf="/root/conf" +server="$conf/server" +user="$conf/user" + +# create dir for configs && set umask +mkdir -p $server && mkdir $user && umask 077 $conf + +# create server keys +wg genkey | tee $server/privatekey | wg pubkey > $server/publickey +priv=`cat $server/privatekey` +pub=`cat $server/publickey` + +# create user keys +wg genkey | tee $user/privatekey | wg pubkey > $user/publickey +upriv=`cat $user/privatekey` +upub=`cat $user/publickey` + +# get server ip +ip=`curl ifconfig.me` + +# generate server config +cat > $server/wg0.conf < $user/user.conf <