In this tutorial, we will how it is easy to setup your own VPN server on Ubuntu under 5 minutes.
Protecting your privacy when surfing online is getting more and more complicated every day. With more and more systems compromised daily, the protection of your browsing data is hard to be assured.
Using a VPN is a great way to retain privacy by routing traffic through your very own VPN server. Instead of routing the traffic directly to the website you are visiting, traffic between your device and the VPN server is encrypted and then continues to the source website. That means the destination sees all traffic coming from your VPN server instead of your ISP, keeping your personal information secure.
Instead of paying for a VPN provider, you should consider creating your VPN server. It is much simpler than it looks, and can complete in less than 5 minutes.
Creating a personal VPN server is key to protecting your online privacy. Any time you use a public WiFi network like in a coffee shop or hotel, you don’t have any idea where to redirect your browsing data to.
- A HostnExtra dedicated server.
- Ubuntu OS
- We recommend you to go with 1GB RAM.
- 10GB of disk space for OpenVPN and other system packages
Let’s start with the installation.
Login into your server using SSH with root user access.
1. Keep your server updated
# apt-get update -y
2. Install required program
If your server does not have the wget program (used to download the installation script) we’ll download it now:
# apt-get install wget
3. Download the Installation Script
Next, we’ll download a popular OpenVPN installation script from github:
# wget https://git.io/vpn -O openvpn-install.sh
4. Update file permissions
Let’s update the permissions on the file to make it executable:
# chmod +x openvpn-install.sh
5. Start the install process
Now to begin the install process by executing the installation script:
Enter this information on the installation script:
The primary IP of the server is automatically filled. Hit enter to proceed.
- Hit 1 to proceed with UDP installation.
- Hit enter to proceed on the default port.
- Enter the DNS provider you wish to use on the server. We recommend OpenDNS.
- Enter your name to be used when generating the client certificate and hit enter.
- Hit enter to proceed with the installation.
- The script will install OpenVPN and generate all of the required keys for usage.
The script will install OpenVPN and generate all of the required keys for usage.
6. Copy VPN Configuration File
Execute the following command and copy the data into a text file on your computer.
# cat /root/client.ovpn
Save the file as client.ovpn.
You can use scp to download the file on your local machine from the terminal
# scp user@IP:/root/client.ovpn /Local/folder
Once downloaded, you can use this file in your favourite VPN client to connect.
7. Adding VPN Users
Each device that you use should have it’s own user on the VPN server to run reliably. You can run the following command to add users:
Selection option 1, and generate a unique name for the device.
Copy the content from the configuration file to use it on your device. For example, if you named the client phone then you can run this command:
# cat /root/phone.ovpn
8. Starting, Stopping, and Restarting OpenVPN
After installation, OpenVPN will start automatically and will be set to start at boot. Here are the start and stop commands for your reference:
To start OpenVPN:
# systemctl start firstname.lastname@example.org
To stop OpenVPN:
# systemctl stop email@example.com
To restart OpenVPN:
# systemctl restart firstname.lastname@example.org
That’s it. Now, configure the VPN in your local machine and enjoy your VPN.
In this tutorial, we have seen how it is easy to setup your own VPN server on Ubuntu under 5 minutes.
[Need assistance to fix this error or install tools? We’ll help you.]