Yasser Adel Mihraban (Yashents)
Sometimes you may want to go online without anyone watching. This may be due to restrictions imposed by governments, ISPs, etc. Maintaining privacy while using the internet is very important for some people, and for me personally, the experience has been bypassing the ridiculous censorship of sites like Twitter and programs like Telegram.
So I thought about how hard it would be to set up a VPN server (because I didn’t want to pay $5/month) for a web developer. After a bit of Googling, I found out that you can easily do this on AWS for free using OpenVPN. I started setting it up and after a few minutes I got it up and running.
OpenVPN is a popular, well-tested open source tool that gives you a production ready VPN solution.
So just in order not to forget how you did it, as usual I thought let’s write something, and who knows, maybe it will be useful to you too 😉.
are you ready?
AWS . Console
If you don’t have an AWS (Amazon Web Services) account, start creating one. It’s free, but you’ll need to have your credit card information handy.
Once registered, login and under the Services menu find EC2 (you can type and it will filter the services as you type).
Click on EC2 and you will be redirected to its control panel. Click the Run Instance button under the Create an instance section.
Several articles will guide you through setting up a new Linux VM and installing a file OpenVPN manually. However, things have changed and some lovely folks have put a ready-to-use service on the AWS Marketplace, so we’re going to pick that one up.
Once in the dashboard, click on the AWS Marketplace menu from the left and type OpenVPN, then press enter.
Click the “Select” button on the first button with the eligible free tier badge.
Choose an instance type
On the next page, click Continue and select t2.micro from the Instance type list.
At this point, press Review and start up button.
Run the instance
Select a general purpose SSD from the popup and click Next. Now click Run and you will see a popup asking you to select a key pair. This is to allow you to access the instance later.
Select Create a new key pair (or an existing one if you already have it), enter a name and click Download key pair.
Keep the .pem file in a safe place because this is like a back door to your server 😁. Click Launch Instance and wait for the instance to go into the running state.
Click View Instance to see the list of instances.
Select your instance and click Connect.
You will see a set of instructions in a popup on how to connect to your instance.
In the instruction set, they ask you to use PuTTY to connect to your instance using SSH. However, I already have Ubuntu setup in WSL (Windows Subsystem for Linux) and we can use that. Otherwise you can use PuTTY or even a web browser connection.
Before we do anything we need to set the permissions for our private key file 👉🏽 .pem 👈🏽 , otherwise it won’t allow you to connect. If you are using a Linux or Mac, just run the following command:
chmod 400 file name.pem
For the rest like me, right click on the .pem file and click Security > Progress. Then change the owner to yourself, click Disable inheritance and remove all permissions. Click add and add yourself and give full control.
Once this is done, open a command prompt, type bash and then enter the following command:
sudo ssh -i “name-of-file .pem” firstname.lastname@example.org
Don’t forget to replace the file name with whatever you chose earlier and replace the server name with what you got from the popup help window.
Type Yes to the agreement, then press Enter to confirm all default settings. Once you reach the end, change the user password that will be used to log in:
Enter a new password twice and you are good to go. Open a browser window and type https://server address:943/admin and login with openvpn and the password you just set.
Arrange some settings
Once in the OpenVPN admin control panel, click Configure and apply the following changes:
- Change the toggle to Should a client’s internet traffic be routed through a VPN? to Yes
- Change the toggle to Ask customers to use specific DNS servers to Yes
- Select your custom DNS server and set the first box to 18.104.22.168 (CloudFlare DNS 🦄) and the second to 22.214.171.124
Now save the settings, wait for the popup at the top and click Apply changes to server.
are you okay
You are all set. Now you can connect to your own VPN server and enjoy private network browsing 😎. On the first page of the browser window you opened earlier, there are five options for downloading the OpenVPN client for a different platform. If you click on windows you will get an installer with your server address preconfigured. Just enter your username and password and voila.
Hope this helps you if you need to setup VPN server for free.