Skip to content

Instantly share code, notes, and snippets.

@benheise
Last active February 12, 2022 07:23
Show Gist options
  • Select an option

  • Save benheise/fee15e0b9dfc2e7455ffed825b03cdd2 to your computer and use it in GitHub Desktop.

Select an option

Save benheise/fee15e0b9dfc2e7455ffed825b03cdd2 to your computer and use it in GitHub Desktop.
Quick and easy Wireguard VPN
This guide assumes the DigitalOcean provider will be used, and a droplet will be generated on a Windows 10/11 host with WSL2 installed, using a Debian VM. Terraform and Ansible will be used to create and destroy the VPN droplet. After that, the Wireguard client configuration in "wg0.conf" can be used on your desktop, laptop, mobile device, etc. You should generate a new Wireguard client per each device, rather than reusing the same one across multiple.
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install unzip wget git apt-add-repository software-properties-common gnupg
wget https://releases.hashicorp.com/terraform/1.0.11/terraform_1.0.11_linux_amd64.zip -O terraform.zip; unzip terraform.zip
sudo mv terraform /usr/local/bin; rm terraform.zip
sudo apt-add-repository ppa:ansible/ansible
git clone https://github.com/P0ssuidao/terraguard.git
cd terraguard/DigitalOcean/
terraform init
terraform plan
Create an API token (read/write) at https://cloud.digitalocean.com/account/api/
sudo terraform plan -var "mobile=true"
# You will be prompted for your digital ocean API key you created previously.
sudo terraform apply -var "mobile=true"
# You will again be prompted for your digital ocean API key.
# terraguard will now be deployed.
# A QR code will be generated, if using a mobile device then scan it and you are all set.
# If you are using your desktop, the wireguard config is in your local temp directory and can be
# copied into your documents folder to be imported into your Windows wireguard client.
sudo cp /tmp/terraguard-mobile.conf /mnt/c/Users/<USERNAME>/Documents/client.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment