Setup Your Own VPN in Cloud

Harshal kondke
3 min readSep 1, 2020

Setting up your own VPN server will make sure that you get good bandwidth as you are only user using the server. and also you can’t steal data from yourself ;)

VPN can be very useful sometime when you want to access Geo restricted content or websites. I mostly use VPN for torrent and i feel free VPN are to slow while downloading the files. so why not to make your own server and get full bandwidth. (Also, I’ll get content to write a blog. haha…)

Actual blog start from here….

As usual i’ll go the most simple and fastest technique.

We will be using OpenVPN. It is a free and open source tool. We will install it in Ubuntu server. for that you can get a Virtual Machine from any of your favorite cloud provider. Just make sure you choose base image as Ubuntu 18.04

Here are some resources on how to start & login into Virtual Machine.

Prerequisites:

  • Virtual Server Running Ubuntu 18.04

Follow the tutorials given above and once you created a server, SSH into it and update it

sudo apt-get update && upgeade

We will download a executable script from GitHub so we need to have git install in our server.

sudo apt-get install git

Install OpenVPN on Ubuntu:

Below git repo has a shell script that can install and setup everything within few mins. Clone this repo…

sudo git clone https://github.com/Nyr/openvpn-install.git

Once the repo is cloned, Change directory to openvpn-install

cd openvpn-install/

To run the script we need make it executable by typing in following command

sudo chmod +x openvpn-install.sh

Run the script openvpn-install.sh

sudo ./openvpn-install.sh

Now we need to set basic configs like IP, protocol, port and certificates

  • Add your servers public IP in Ipv4 block
  • Select UDP
  • set port as 1194
  • Choose either a 1.1.1.1 or Google DNS as they are highly available
  • Name of a client(You can put your name here)
  • Hit Enter
Welcome to this OpenVPN road warrior installer!I need to ask you a few questions before starting setup.You can use the default options and just press enter if you are ok with them.This server is behind NAT. What is the public IPv4 address or hostname?Public IPv4 address / hostname [192.168.100.55]: 192.168.100.55
Which protocol do you want for OpenVPN connections? 1) UDP (recommended) 2) TCPProtocol [1]: 1What port do you want OpenVPN listening to?Port [1194]: 1194Which DNS do you want to use with the VPN? 1) Current system resolvers 2) 1.1.1.1 3) Google 4) OpenDNS 5) VerisignDNS [1]: 3Finally, tell me a name for the client certificate.Client name [client]: HarshalOkay, that was all I needed. We are ready to set up your OpenVPN server now.Press any key to continue... Press Enter

Once it the script completed setting up your account, you see the location of your .ovpn file.

it maybe /home/username/Harshal.ovpn or /root/Harshal.ovpn

You need to download this file into your local system. you can refer this answer on stack overflow to know about how to download files via ssh.

or simply you can view the file with following command and copy the data and create a new file in local system and past it there.

cat /home/ubuntu/Harshal.ovpn

Now just make sure you have made change in firewall/security group and allow all incoming traffic using UDP protocol for 1194

Okay. Now server is ready to connect

Lets connect the server with your device:

Download your compatible software and add your .ovpn file to it and you are good to go.

PS: with this method you can only make 2 users for one server.

Happy Coding :)

Cheers,

--

--