Install Pritunl on your ECS Alibaba Cloud

Pritunl is an open source tool which having server monitoring and user management. Pritunl doesn’t need high spec VPS (VM Server), support installation on various Linux operating systems. Pritunl mostly used as VPN Server. VPN Server used to provide you access to other websites safer by changing connection line through server and hide the data exchange.

Preliminary

In this article, we are going to use CentOS 7.8 as our Image.

Pick Centos 7.8

For billing method, better use Pay-As-You-Go if you don’t have subscription plan to reduce cost.

Billing Method

For instance type, it depends on you. I choose low spec (1 vCPU and 1 GB Memory).

Instance Type

Disk, i set it default.

We need Public IP, so we assign Public IP on our ECS instance. And for Bandwidth Billing, it depends on you. Pay-By-Bandwidth seems expensive.

Network Configuration

For VPC and VSwitch, i think you can easily set it.

For security group, you will need to add/open port for Pritunl Service. We will add the port later, because we still don’t know what port will be used.

Next, for credential. It depends on you. Using Key Pair is the best practice in logon credential, but if it’s for experimental purpose, it’s ok.

Key-Pair

If the requirement already been fulfilled, you can preview your order and create. [don’t forget to confirm T&C].

If it already been created, you can see it on your ECS console.

ECS Instance

Firstly, we will add repo for mongodb and repo for pritunl as well.

Secondly, install epel-release package.

Thirdly, edit selinux config.

Then, install pritunl.

Next, install mongodb

After that, you need to setup key for pritunl, you need to setup authentication, add organisation, add user, add server and attach your server to organisation you choose.

Finally, your Pritunl server can be accessed and enter your setup key there.

Implementation

1. Add Repo

1.1 For MongoDB

# vi /etc/yum.repos.d/mongodb-org-3.4.repo

add MongoDB repo

1.2 For Pritunl

# vi /etc/yum.repos.d/pritunl.repo

add Pritunl repo

2. Install Epel-Release package

# yum -y install epel-release

3. Edit Selinux. Config

# vi /etc/selinux/config

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=enforcing . 
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected, 
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

Change config from “SELINUX=enforcing . ” to SELINUX=Disabled

Change config SELINUX

4. Instalation

4.1 For Pritunl

We need to add these keys before installation

# gpg –keyserver hkp://keyserver.ubuntu.com –recv-keys 7568D9BB55FF9E5287D586017AE645C0CF8E292A
# gpg –armor –export 7568D9BB55FF9E5287D586017AE645C0CF8E292A > temp.tmp; sudo rpm –import temp.tmp

And then, remove the temp key file.

# rm -f temp.tmp

Then, freely to install the pritunl

# yum -y install pritunl

4.2 For MongoDB

For installing MongoDB, you can execute this syntax.

# yum -y install mongodb-org

After installation already been finished, you can start and enable both services by these syntax.

# systemctl start mongod pritunl
# systemctl enable mongod pritunl

5. Setup Pritunl

5.1 Key

Generate the setup key by execute this syntax.

# pritunl setup-key

Now, go to your https://IP-ADDRESS

Go to your pritunl web page

Enter the setup key (after you execute the previous syntax, copy-paste on the form.

5.2 Authentication

After you click save, it will redirect you to login page.

Pritunl’s Login Page

execute this syntax to get your username and password.

# pritunl default-password

Pritunl’s Default Authentication

Next, you will be redirected to dashboard page and need to change your authentication/initial setup.

Initial Setup

6. Config on Web

6.1 Add Organisation

On left section (upper left) you can see the Users menu, click it and go to add organization.

Steps to reach Add Organisation feature
Add Organisation

6.2 Add User

On left section (upper left) you can see the Users menu, click it and go to add user.

Step to reach add user feature
Add user (select organisation)

Set the others as default, fill the name and select an organisation.

Example for Add User

6.3 Add Server

On left section (upper left) you can see the Server menu, click it and go to add server.

Step to reach add server feature
Add Server

Nb. Don’t forget to add your incoming traffic (ingress) on Security Group. (Choose UDP protocol and set port as you mentioned on Pritunl same like on Security Group)

Modifying Security Group

6.4 Attach server to your organisation

On left section (upper left) you can see the Server menu, click it and go to attach organisation.

Step to reach attach organisation feature
attach your organisation

After organisation was attached, you can start server.

Verification

As testing user, we will try the VPN. As opening, you need to copy temporary profile link which including your vpn profile (user account). You can download your user profile (zip/without zip/others), and import your .ovpn to your Pritunl Client.

Copy temporary link
Downloading Profile

Already been connected to vpn server.

When i check my IP, it returns my ECS’s Public IP. Because we communicate through the connection of ECS’s Public IP.

References

https://www.vultr.com/docs/installing-pritunl-on-centos-7

Published by boy.suganda

My name is Boy Suganda Sinaga. I worked as Site Reliability Engineer (SRE) at Shipper Indonesia. I'm still developing my skill, both hard-skill and soft-skill. Let's work together, to bring better future for others.

Leave a Reply

Your email address will not be published. Required fields are marked *