Harness AWS Hosting and OpenVPN for Secure, Cost-Free Browsing

Free 12-month Vpn Now Openvpn on Aws Ec2 Ubuntu!

Harness AWS Hosting and OpenVPN for Secure, Cost-Free Browsing

Home » Blog » Cookbook » Cloud » AWS » Ubuntu » OpenVPN » Harness AWS Hosting and OpenVPN for Secure, Cost-Free Browsing
Say Goodbye to your VPN Costs! Unleash Secure Browsing with this Free Tier of AWS EC2 Ubuntu Server & OpenVPN Guide.
Table of Contents

Have you considered harnessing the power of AWS Hosting and OpenVPN to curb your skyrocketing VPN service costs? If your bills are burning a hole in your pocket, it’s time to explore an alternative solution: setting up OpenVPN on an Ubuntu EC2 instance with AWS Free Tier. This technical task becomes a piece of cake using the AWS console, even for the uninitiated.

Absolutely free for the first year, this setup empowers you to surf the internet securely from any corner of the world without worrying about pricing. Our step-by-step guide simplifies the installation and configuration process, ensuring that you can easily transition to this cost-effective, secure internet browsing solution. Time to bid farewell to exorbitant monthly bills and embrace the freedom and security of OpenVPN on AWS Free Tier.

What is OpenVPN?

OpenVPN is a widely recognized, open-source software solution that helps create secure point-to-point or site-to-site connections in routed or bridged configurations and remote access facilities. It utilizes a custom security protocol that uses SSL/TLS for key exchange, providing a versatile and powerful privacy tool for your online activities. The OpenVPN download on your server is essential to unlocking these benefits. We will not use the official release; that takes time. We will use the repository from Git for OpenVPN download and installation. By acquiring the OpenVPN client, users have the necessary software to establish a secure connection with the OpenVPN server. For Android or iOS or even Windows and Mac, the app is called ‘OpenVPN connect,’ which enables secure data transmission across the internet. OpenVPN offers a robust solution for anyone concerned about online privacy. With easy-to-follow setup procedures, protecting your online activities’ has never been simpler. So why wait? Start your journey towards secure, private internet browsing today with OpenVPN.

Prerequisites to Install OpenVPN on Linux (AWS EC2 Ubuntu Instance)

I’m guessing you have accessed the AWS EC2 Ubuntu 22.04 Instance via PuTTY, MobaXterm, or any SSH Terminal already. Let’s start after that,

How to Install OpenVPN Server on AWS EC2 Ubuntu Instance

Get root Privilege

Get Root Privilege or Aws Ec2 Ubuntu 22.04 Instance with Sudo -i
Get root Privilege with sudo -i

Geitting root privilege is the first thing you need to do. Just copy and paste the following command to your AWS EC2 Ubuntu terminal

SSH Config
sudo -i

OpenVPN download using openvpn-install.sh script to set up OpenVPN server

Download Openvpn-install.sh Script for Fast Installation by "wget Https://git.io/vpn -o Openvpn-install.sh"
Download openvpn-install.sh script for fast installation

Type the following wget command or simply copy and paste it on your terminal

SSH Config
wget https://git.io/vpn -O openvpn-install.sh

Verify the openvpn-install.sh script (optional)

Verify the Openvpn-install.sh Script by "cat Openvpn-install.sh" Command
Verify the openvpn-install.sh script

Additionally you can verify the script by concatenate or following cat command.

SSH Config
cat openvpn-install.sh

Make openvpn-install.sh script executable

Make Openvpn-install.sh Script Executable
Make openvpn-install.sh script executable

Copy and Paste the following command on your ssh client to make openvpn-install.sh script executable on the AWS EC2 ubuntu server.

SSH Config
chmod +x openvpn-install.sh

Execute (Run) the openvpn-install.sh script

Execute the Openvpn-install.sh Script Using Bash Openvpn-install.sh on Your Ssh Client
Execute the openvpn-install.sh script

Copy and paste the following command into your ssh client and hit enter to start the installation

SSH Config
bash openvpn-install.sh

Choose your parameters for OpenVPN installation

Enter Your Openvpn Host, Protocol, Port, Dns and First User for Openvpn Connect
Enter your OpenVPN host, protocol, port, DNS and First User to be used by OpenVPN Connect
  1. Here you need to enter your hostname at the first step. I have used ovpn.roosho.com. It is not mandatory. You can always hit enter to go to next step if you don’t have a domain. But I recommend it. If you have enter the hostname, follow this instruction to add it into your domain control panel.
  2. In step 2 Select 1 for UDP or 2 for TCP as the OpenVPN Protocol. I’ve selected UDP. You can just Hit Enter if you also want to keep UDP which is default.
  3. Step 3 is selecting the port. Here I’ve selected port 8888. That makes my VPN port UDP 8888. Here also you can Hit Enter and Continue with the default port 1194. Whatever you choose, don’t forget to add the inbound rule for that port inside Security Groups of that Instance on aws amazon console.
  4. In step 4 choose your DNS server, I’ve chosen Google, because it is my personal favorite. I wouldn’t recommend choosing the default here, only for my lack of knowledge of AWS DNS server. If you are an expert and know better about AWS DNS Server, you can choose though.
  5. Enter the name of your first client. I’ve entered roosho. Da…
  6. Hit enter to complete your installation.

Get the configuration file to use in OpenVPN Connect

Get the Configuration File to Use in Openvpn Connect
You can actually see the configuration file location at the end of the installation

You can actually get the ovpn file location which you need to use on OpenVPN Connect at the end of the installation. If you still can’t find the file try the following command.

SSH Config
find / -type f -name "r_roosho.ovpn"

My OVPN is r_roosho.ovpn. Change your filename accordingly. If you don’t know what is the name of your OVPN file use the following.

SSH Config
find / -type f -name "*.ovpn" -ls

Copy the OVPN file to your Computer

It is actually hard to get direct access to the root directory of the AWS EC2 Ubuntu Server, and also time consuming. The easiest way is to just copy what’s inside it using cat. Simply enter the following command. Change the filename according to your installation.

SSH Config
cat r_roosho.ovpn
Get Your Ovpn File Content
ls to list the files and identify your file. cat to view the file

Once you see it, copy everything inside it.

Paste everything from inside your OVPN file to Notepad

Then paste it on a notepad on your computer and save it with an OVPN extension.

Save it with OVPN extension

How to Add Inbound Rule to AWS Firewall

  • Select your AWS EC2 Ubuntu Server
Select Your Aws Ec2 Instance for Selecting the Security Group
Select your AWS EC2 Instance ID
  • On the Security Tab and select Security Group.
Security Group Selection
  • Click on Edit Inbound Rules to add another Inbound Firewall Rule
Edit Inbound Rules
  • Click on Add rule
Click on Add Rule to Add Your Inbound Rule
Click on Add rule to add your Inbound rule

Select Type as Custom UDP, Port range whatever you set(in my case 8888). and IP Range 0.0.0.0/0 for all IPv4, lastly Optional Description if you want to add Click on Save rule.

Select Your Inbound Port Details
Select your inbound port details

How to add DNS to your Hostname of your domain

Add Dns to Your Hostname in Your Domain Control Panel
Add DNS to your hostname in your domain control panel

If you have used a hostname like mine, Go to your Domain Control Panel and then add an A Record with your domain. Enter hostname from your hostname.domain.com in place of Name textbox Enter your AWS EC2 Ubuntu Instance (Ubuntu Server) IP in place of DNS (In my case hostname is ovpn and DNS is 13.42.64.77). If you are using CloudFlare, please please please, don’t forget to turn off your Proxy. And Save it. Done.

Now you can use it on any devices. Let’s see how to use it on Android Smart Phone.

How to use OpenVPN on Android using OpenVPN Connect

  • First of all Download the OVPN on your Smartphone. If you don’t have any easy way like Microsoft Phone Link or KIES or PC Suit, You can use HFS to create a temporary HTTP URL within seconds. If you don’t know how, I don’t know why, Just follow this guide of How to Create your Http File Server in seconds with HFS.
  • Download and Install the OpenVPN Connect from PlayStore in your Android Smartphone. Go to this link if you are on Your Phone right now.
  • Open the Open VPN application.
  • On the Left Hamburger Menu Select Import Profile.
Go to Import Profile
  • Import the OVPN file from the download location to your OpenVPN Connect App.
Tap Upload File and Browse the file location
Select the OVPN File
Tap OK to complete Import
  • Connect to your VPN and check you IP from web Browser.
Connect to OpneVPN Server
Observe if you have connected
Check your IP from Browser

How to Review OpenVPN Installation on Ubuntu Server

OpenVPN Firewall Configuration

Review your OpenVPN Firewall on Ubuntu Server

You can review the added firewall rules by the following command.

SSH Config
systemctl cat openvpn-iptables.service

OpenVPN Configuration

Review Overall Openvpn Configuration
Review overall OpenVPN Configuration

Review your overall OpenVPN Configuration using the following command.

SSH Config
sudo more /etc/openvpn/server/server.conf

How to see Status of your OpenVPN Service on Ubuntu Server

Start OpenVPN Service

Start Your Openvpn Service
Start your OpenVPN Service

To start OpenVPN Service on your Ubuntu Server use the following command (if needed).

SSH Config
systemctl start [email protected]

Stop OpenVPN Service

Stop your OpenVPN Service

To stop OpenVPN Service on your Ubuntu Server use the following command (if needed).

SSH Config
systemctl stop [email protected]

Restart OpenVPN Service

Restart your OpenVPN Service

To restart OpenVPN Service on your Ubuntu Server use the following command (if needed).

SSH Config
systemctl restart [email protected]

Status of your OpenVPN Service

Status of your OpenVPN Service

To see the status of your OpenVPN Service on your Ubuntu 22.04 Server use the following command (if needed).

SSH Config
systemctl status [email protected]

How to add a new user to OpenVPN

Initiate Bash to Add New User
initiate bash to add new user

Enter the following command to start Adding new user to your OpenVPN Ubuntu Server

SSH Config
bash openvpn-install.sh
Enter User details

Enter 1 and Press Enter then write the name and Hit Enter to create a new user on your OpenVPN server.

In conclusion, setting up your own VPN server using AWS Free Tier and OpenVPN can be an efficient and cost-effective solution to secure your online activities. This guide provides detailed step-by-step instructions on how to leverage the power of AWS and OpenVPN, offering you a robust privacy tool at your disposal. With AWS Free Tier, you can enjoy this service free of cost for the first year, potentially saving you a significant amount on your monthly bills.

However, the technical nature of setting up a VPN server can be a daunting task. But fear not, the outlined guide has simplified the installation and configuration process for you. From gaining root privilege, downloading and executing OpenVPN scripts, to setting up your parameters and importing the configuration file, each step is clearly laid out for you. You can also learn how to manage the OpenVPN service on your Ubuntu Server and add a new user when needed.

Furthermore, this guide extends to demonstrating how to use the OpenVPN on an Android smartphone, making your secure browsing experience mobile.

Yet, no setup is entirely devoid of challenges. If you encounter any issues, need help troubleshooting, or simply need assistance in understanding any part of this guide, do not hesitate to reach out. I am here to help ensure that you successfully transition to this secure, private, and cost-effective internet browsing solution.

Yet, no setup is entirely devoid of challenges. If you encounter any issues, need help troubleshooting, or simply need assistance in understanding any part of this guide, do not hesitate to reach out. I am here to help ensure that you successfully transition to this secure, private, and cost-effective internet browsing solution.

Remember, your online privacy is paramount and taking these steps to secure your internet browsing is an investment in your own digital safety. Embrace the freedom and security that comes with using OpenVPN on AWS today.

share this article.
I am Rakib Raihan RooSho, Jack of all IT Trades. You got it right. Good for nothing. I try a lot of things and fail more than that. That's how I learn. Whenever I succeed, I note that in my cookbook. Eventually, that became my blog. 
I am Rakib Raihan RooSho, Jack of all IT Trades. You got it right. Good for nothing. I try a lot of things and fail more than that. That's how I learn. Whenever I succeed, I note that in my cookbook. Eventually, that became my blog. 

Enjoying my articles?

Sign up to get new content delivered straight to your inbox.

Please enable JavaScript in your browser to complete this form.
Name