Set Up a Free VPN Server in AWS
A Virtual Private Network (VPN) is a way to maintain online anonymity by masking your public IP address so your online activity is untraceable. There are a ton of VPN services and apps available out there, most of which have paid plans, but in this post I am going to demonstrate how you can set up your own, for free. Let’s get started.
Create an account in AWS
We first need to have an account with AWS set up. So head over to this link to create your account.
Fill in all the required info, then proceed below.
Login to your Management Console
Once you sign in to your Management Console, head over to the Services
tab and under Compute
, click on EC2
. You can read more about EC2 here. Once that loads up, click on the Launch Instance
button.
On the left panel, click on AWS Marketplace
. On the search bar, search for openvpn and look for the “free tier eligible” sign for the OpenVPN Access Server
then select it. Scroll down and click on Continue
. OpenVPN Access Server by OpenVPN Technologies, Inc. is a full-featured SSL VPN software solution that integrates the open-source OpenVPN server capabilities with additional features. Those features include a simplified administration web interface and automated certificate management to easily issue user certificates and keys without necessarily requiring an existing public key infrastructure (PKI).
Create a new key pair
Select the t2.micro
option with the “free tier eligible” option then click Review and Launch.
On the bottom right corner click on Launch
and a pop-up menu should appear. On the pop-up menu select Create a new key pair
, give it a name then download it. Take note of the location you download it in your computer. Once you download it, click on Launch Instances.
This will take a while but once it finishes, click on your Instance ID to take you to your dashboard. Click on Connect
.
Set up the SSH Client on your local machine
Select the ssh client
tab and copy the Example command. I’m on a Windows machine as I do this, those on Linux and Mac can use the terminal. Meanwhile I’ll use PowerShell. Paste the command and run it. Make sure you have the correct path of your key pair file within the command. Mine looks like this: Downloads/liciovpn.pem.
Accept the licenses as well and keep everything else as default. It will then prompt you to run the command as openvpnas rather than root. Just replace root
with openvpnas
. Like below:
ssh -i Downloads/liciovpn.pem openvpnas@ec2–3–17–61–207.us-east-2.compute.amazonaws.com
Next, we need to set up our password to something we can remember. Run the command sudo passwd openvpn to change your password.
Test it out on your browser
On your Instances
tab in AWS, click on your Public IP Address on a new tab like this:
https://mypublicipaddress:943/admin
To enable OpenVPN to work well in this situation, by default the OpenVPN daemon listens on the TCP port 443 and can forward incoming web browser requests to a web service on port TCP 943 (since you cannot have both the web server and the OpenVPN server listening on the same port). You are then able to bypass existing firewall limitations.
Login using your username openvpn and the new password you set. Once you login click on Agree to accept the terms. Under the Configurations
tab click on VPN Settings
. Under the Routing
section, for the question Should client Internet traffic be routed through the VPN? Switch to Yes, scroll down and Save Settings.
Click on Update Running Server
to update your changes. On the URL bar, remove the admin/vpn_settings from the URL, the new URL should look like this: https://mypublicipaddress:943. Once logged in, choose the OS you’re on and download it then install it.
Once installed, sign in once again using the username openvpn and the password you had set earlier. Flip the switch and start using your free VPN server in the cloud.