OpenVPN is an open-source software that implements VPN.It is used for creating the peer to peer connections. It is more than 16 years old. The first release was on 13 May 2001. But we will not go into details of explaining what is OpenVPN is, but instead we will go through how to install Open VPN on the cloud.
For this post, I am using Free Tier provided by Amazon web services [aws.amazon.com/free].
We are going to install OpenVPN server and OpenVPN client on your local machine, so first, you need an AWS account. Login to your AWS account and goto EC2 Dashboard and launch an instance.
Then goto AWS marketplace and search for OpenVPN and select OpenVPN Access Server
I am going to select t2.micro as it eligible for the free tier and hit review and launch.
Here I am going to select General Purpose (SSD) and hit next.
After that AWS will skip to step number 7 where we need to review the Instance. After review hit launch.
It will take few minutes to reach running states till then we will create an elastic IP so that the IP will not get lost. In order to create Elastic IP hit Elastic IPs in the left panel of EC2 Dashboard. Hit Allocate New Address and you will get an Elastic IP.
Now associate that address with your instance you have created earlier for OpenVPN.
After that, Elastic IP will link to that instance and become public IP of that instance.
Now we have to SSH into the instance. This is a one time process. User for ssh will be openvpnas.
When you enter into the instance you will get this message. Enter yes and hit enter to continue.
Now keep pressing enter till Initial Configuration Completes
Once the configuration completes change the password for openvpn user. Enter
Now open the browser and goto the elastic IP address in location bar with https protocol. For example, I am going to use https://220.127.116.11 this will prompt a warning message as shown below. You just need to skip it and process to the URL.
It will ask you for login in the panel where you can enter openvpn as username and the password that you set earlier as the password. Then after you need to install OpenVPN client as I am working on Linux I am going select OpenVPN for Linux which will take you to this page https://openvpn.net/index.php/access-server/docs/admin-guides/182-how-to-connect-to-access-server-with-linux-clients.html
Just install OpenVPN client on your machine and download the user-locked profile which will be used to connect to Open VPN.
Connect to Open VPN using following command
In order to connect, you must have root access.
Once it is done go to admin panel by appending /admin after your URL. For example, https:///admin and it will take you to admin login page where you need to enter the same credentials as before.
At the first time it will ask you to agree upon its term, just hit agree and you will enter into the admin panel.
Then go to Server Network Settings menu and unchecked Admin Web Server and Client Web Server and hit save. It will disable access to your Web Servers from public IP.
Now it will show the message saying Setting changed, hit Update Running Server and you will get site cannot be reached error which we intended to do.
Now go to EC2 dashboard and get the private IP of your instance.
Now go to web browser and replace public IP with private IP and append :943 at the end of the IP. URL should be like https://:943/admin. It will take you to the admin panel and that’s it. Now those who are connected to Open VPN will able to access the server using private IP. That’s it your OpenVPN is now up and running.
Just a note for security measures you can remove SSH login from security groups.