commit b1ccce7f23b48a23390b0c3f62f6f7597a871095 Author: Ayush Mukherjee Date: Mon May 27 14:09:41 2024 +0530 chore: init repo 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 <