DEV Community

Henrique Santos
Henrique Santos

Posted on

Create VPN Client to site Open Source in AWS EC2 (PrituNL)

  • Create instânce EC2 in public subnet, i used t3a.micro instance type (in tutorial i use Ubuntu 20.4).
  • Add Elastic IP in your instance.
  • In Route 53 add record subdomain >>> elastic ip
  • In Security Group add roles
  1. - 80 >> 0.0.0.0/0
  2. - 443 >> 0.0.0.0/0

Step 1: Update your system

sudo apt update && sudo apt -y full-upgrade

[ -f /var/run/reboot-required ] && sudo reboot -f

Enter fullscreen mode Exit fullscreen mode

Step 2: Add Pritunl, MongoDB repositories and public key

echo "deb http://repo.pritunl.com/stable/apt $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/pritunl.list

echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu $(lsb_release -cs)/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list

curl -fsSL https://www.mongodb.org/static/pgp/server-5.0.asc|sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/mongodb-5.gpg

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com --recv 7AE645C0CF8E292A

sudo apt update
Enter fullscreen mode Exit fullscreen mode

Step 3: Install Pritunl and MongoDB

sudo apt --assume-yes install pritunl mongodb-org

sudo systemctl start pritunl mongod

sudo systemctl enable pritunl mongod

Enter fullscreen mode Exit fullscreen mode

Step 4: Configure Pritunl on Ubuntu 20.04

Access console vpn
https://YOUR_ELASTICIP

  • In Ubuntu terminal run comands for get initial password
sudo pritunl setup-key
Enter fullscreen mode Exit fullscreen mode
  • Add key generete in your console vpn
sudo pritunl default-password

Enter fullscreen mode Exit fullscreen mode
  • Login in console vpn with these credentials, and go to Settings.

  • In settings rename admin user and change passaword.

  • In Lets Encrypt Domain, add your domain for get SSL acces with certificate and save.

Step 5: Configurate Server

  • In server, Add new server.
  • In console aws, give acess for 0.0.0.0/0 for port your server.
  • DNS server, if you want private access only, add DNS server of yours VPC and save.

Step 6: Add route

If you want access in your VPN only, click in Add route, and put your VPN CIDR, and remove route 0.0.0.0.

Step 7: Organization

  • In User, click in add organization,come to server, seletct your server and add your organization in your server.

  • After this, create your users and give URL for access.

Top comments (0)