How to Set Up OpenVPN Server| Beginners Tutorial
Nowadays, Being secure online is a important and a messy part of our life! We try so much to keep ourselves secure with vpn, proxies, etc.
In this tutorial we will learn how to install a OpenVPN Server on your small VPS (yes a small vps with 512gb ram is sufficient!) and using it on your phone or PC.
Before beginning you should be aware of the things which gets help by using VPN
It helps in:
- Unblocking Sites
- Keeping us secure online
- Keeping us secure at any public area where free wifi is available
- DMCA Complaints about pirating (I don’t encourage this anyways!)
- Geeking out :P
Okay lets get started
Getting Started
You need:
- A VPS with Ubuntu, Centos, Debian OS. VPS spec can be low if you are the only one who will be using VPN. Like I recommend a 512mb ram VPS with CentOS 8 Server OS. Get A Small VPS From DigitalOcean (with 100$ free credits).
- Root Access User in VPS.
- If using Windows then install Putty. If using Mac or Linux then no need of any ssh client.
NOTES: Remove $ in command before entering it in terminal
Let’s Start
Step-1: Connecting to Server
Log in on a Mac or Linux
~APS_MAC->$ ssh root@IPaddress
Replace root with your server username and IPaddress with your server IP (ipv4)
Log In through Putty on Windows (Download latest release from Putty)
Enter your IP Address in the required field and your Username and then fire it up!
It will ask for your User Password of the server.
Type it and Press Enter!
Voila! You Just logged into your Server!
Step-2: Installing OpenVPN server
We are going to install OpenVPN server on VPS using this automated script: https://github.com/Nyr/openvpn-install
Why this script is better than manual installation?
This script has everything automated and removes the load on you of managing a openvpn server manually and in meantime you can binge watch something on netflix!
Okay so let’s start installation.
First make sure your VPS has wget installed in it. It comes installed but like in centos minimal installation it doesn’t. So verify it by
Ubuntu/Debian
$ sudo apt-get install wget
CentOS
$ sudo yum install wget
After wget installed/verified we should move forward to installing openvpn server. Install the script with this handy command below
$ wget https://git.io/vpn -O openvpn-install.sh && bash openvpn-install.sh
If you are getting this error:
The system does not have the TUN device available.
TUN needs to be enabled before running this installer.
Then contact the VPS Provider. Or if there’s any option to turn on Tun/Tap from VPS Panel (provided by the VPS provider) then turn it on and Type the Above Command again.
Step-3: Following the on-screen steps
Choose UDP as its fast! It reduces ping time and makes the connection fast!
So type 1 and Press enter
Then,
Let the port be default so simply press Enter.
Then,
This is the main part of all the steps i.e., choosing a DNS Server
As you can see 1.1.1.1 is the fasted DNS Server we will choose it! 1.1.1.1 is a partnership between Cloudflare and APNIC.
So press 3 and press enter.
Then,
Now enter the client name which can be anything like your own name or any random name.
Type it and press Enter.
And Then,
Press Any key and the installation will start :)
After a successful installation you will get the Finished! text with the directory location where our VPN configuration file is stored.
Now The server is running!
All we have to do is now Connecting to VPN from OpenVPN client.
Step-4: Download OpenVPN Client
Download the OpenVPN Connect client from here:
Step-5: Getting the Configuration Files for Connecting to VPN Server
Now we need the configuration file which was made during the installation which will connect us to the VPN server!
Switch to this Directory and list the files there.
$ cd /root/ && ls
As in my Case Amresh.ovpn is my configuration file for connecting to the VPN Server. In general case it will look like client.ovpn (client is the name which you inputted during the installation)
.ovpn is simply a text file which has configuration which OpenVPN can read and will connect to the OpenVPN server.
Okay so let’s copy that config Amresh.ovpn on the desktop.
Type the command(Change Amresh to your client name):
$ cat Amresh.ovpn
Lots of text will appear.
Scroll above Till you reach somewhere as shown below:
Now copy from client word to the end of the text till </tls-encrypt> (included)
And then make a Amresh.txt file on desktop (Change Amresh to your Client Name)
and paste all the copied things into it
And then rename the file to Amresh.ovpn (Change Amresh to your Client Name)
Now let’s connect to VPN :D
Open OpenVPN Connect App
Click on File
And select the Amresh.ovpn File (Change Amresh to your Client name)
And after that it will look like this
And Click on the Slider!!!!
That’s All!
You will get connected :)
Have any doubt? Then Ask in Response box below or comment box below. I will reply asap :)
Written on 31 December 2020.
Happy New Year 2021 :)
Wish you all a Happy and Prosperous New Year!