← All posts

Pritunl - Easiest way to setup OpenVPN

Written in 2016. Commands, versions and links here may be out of date.

Setting up OpenVPN on your own server can be real pain in the a**. I know a lot of you would agree with me there. Today, I’ll show you guys how to setup OpenVPN and manage users without any hiccups. I don’t think this can get any easier. Enter Pritunl. You install a few packages and you’re done. You have a fully functional VPN server with a web interface where you can manage your users, servers, organizations etc.

Update: Use the current Pritunl installation guide#

This post was written in 2016 for Ubuntu 14.04 and MongoDB 3.2. Those versions are obsolete; don’t use the repository URLs, signing-key commands, or package instructions below for a new VPN server.

For a new installation, use a currently supported Linux distribution and follow the official Pritunl installation guide for its supported operating systems, dependencies, and setup steps. Don’t assume the latest release of your preferred distribution is supported—check the guide first.

The original walkthrough remains below for historical reference. I haven’t retested it with current Pritunl releases, so the interface and authentication steps may have changed. Before exposing a VPN server to the internet, follow the current security guidance, use strong credentials, and keep the server updated.

What is Pritunl?#

Pritunl is a distributed enterprise vpn server built using the OpenVPN protocol. It is free and open source. For more information, go to Pritunl.com

How to setup Pritunl in your VPS#

Pritunl should work on any Linux Distro. But, I’d advice you to use Ubuntu 14.04. For this setup, I have a 512MB DigitalOcean VPS running Ubuntu 14.04. Let’s get started

Installing the required packages#

If you’re using anything other than Ubuntu 14.04, go to https://github.com/pritunl/pritunl And follow the instructions corresponding to your distro, install the packages and continue with this article.

If you are using an Ubuntu 14.04 machine, Open a Terminal and issue the following commands one by one.

echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" > /etc/apt/sources.list.d/mongodb-org-3.2.list
echo "deb http://repo.pritunl.com/stable/apt trusty main" > /etc/apt/sources.list.d/pritunl.list

apt-key adv --keyserver hkp://keyserver.ubuntu.com --recv 42F3E95A2C4F08279C4960ADD68FA50FEA312927
apt-key adv --keyserver hkp://keyserver.ubuntu.com --recv 7568D9BB55FF9E5287D586017AE645C0CF8E292A
apt-get update
apt-get install pritunl mongodb-org
service pritunl start

And, that should install and start the Pritunl server on your VPS.

The initial setup#

  • Once the installation is finished, go to https://your-server-ip. You can use the command curl ip.esc.sh to get the public IP of your VPS.
    A self-signed certificate can trigger a browser warning during initial setup. Verify that you’re connecting to your own server and check its certificate before proceeding; don’t dismiss an unexpected certificate warning. Configure a trusted TLS certificate for ongoing use.
  • Run the command pritunl setup-key in the VPS and copy the setup key. Paste it in the web interface. Leave the mongodb url as it is and click save

Create a Server and User#

  • Now click on Servers and then Add server give any name you like, and click “add”
  • Now we need to create an organization and a user. Click on users –> Add organization. Give a name for your organization, and click add.
  • Back in the servers tab, click on attach organization, and then attach the server to the organization you just created.

Create a user and start the server#

  • Click on the users tab, and then Add user. Give a name for the user, and a pin. This PIN is used for authentication. Choose a strong, unique PIN; don’t use a short, predictable value such as “123456”.
  • Back in Servers tab, start the server by pressing “Start server”.

Final steps#

  • Download the configuration from the users tab. It should be a tar file. Extract the tar file and you will get a file in the format “organization_user_servername.ovpn”. This is the OpenVPN config file we will be using to connect to the VPN server.
  • For us to connect to the VPN, we need a vpn client. Go to https://client.pritunl.com/ and download the vpn client depending on your local machine from where you will be connecting to the VPN.
  • Once you have installed the “pritunl client”, open it up. Click on “import profile” and then choose the “ovpn” file we extracted in the previous step. Now click on the three dashes, and click “connect”. It will ask you to enter the pin. Enter the pin you used while creating the user.
  • Wait for it to connect and there you go. You’re now connected to the vpn and all the traffic is now being routed through the vpn.
  • You can verify this by visiting this url ip.esc.sh. It should show your VPS’s IP address.

Have fun :D