Installing OpenVPN on AWS EC2's Ubuntu 22.04 in 5 minutes
kangwijen

I'm a cheapskate and don't want to spend $10-$15/month on commercial VPN services so I've decided to run my own VPN server using AWS EC2 instance. It's cheaper at around $5/month with on-demand instances, cheaper if you go with other type of instances or even free for 1 year, if you have the free trial tier. And you can learn something along the way. While this tutorial should be appliable to any Linux distros, in this guide I'll show you how to do it in a Ubuntu 22.04 instance.
Launching an EC2 Instance
This part is easy, head to your EC2 dashboard in the region you've selected and click the Launch Instance button. That will take you to a new setup page. In the "Name and tags" section, you can assign a name to your instance.

Next, you'll choose the OS image to install. For this guide, I'm using Ubuntu 22.04.

After that, select the instance type. Go with t2.micro if you're using the free tier, or t2.nano if you're aiming for minimal cost. Personally, I’ve been running t2.nano as my main VPN server, and it performs well.

Then you'll be prompted to select or create a key pair file, which is required for logging in to the instance. If you don’t have one, click "Create new key pair". You'll need to name it, choose the encryption method, and pick a file format. Stick with the defaults unless your system requires something specific. The file will be downloaded automatically, store it well and don't lose it (And don't share it to anyone). You're going to access the instance with this file.

In the Network settings section, you can leave the defaults for now, but make a note of the network name since you’ll be modifying it later.

Last section is the storage section, leave it as default.

Configuring the Instance's Firewall
After you've launched the EC2 instance, we're now going to configure the instance's firewall. It should be accessible from the left tab and the option "Security Groups" under the "Network & Security" section.

Remember the network name I told you to remember? Try clicking on the associated security group. It should send you to a new page

On the new page, click on "Inbound rules" and click on "Edit inbound rules" button on the right. Then click on "Add rule"


The set your configuration exactly like this

Click "Save rules" and we're done.
Installing OpenVPN on the EC2 Instance
Click on the "Instances" button under the "Instances" section, then click on your instance and click on connect. You can choose "Connect using EC2 Instance Connect" and leave it as default as it is the easiest way. Or you can use any other way that you like. First thing to do is to elevate our user to sudo and update the OS.
sudo su
apt update -y && apt upgrade -yWait until it's done and now we can install OpenVPN. We'll be using angristan's script to install OpenVPN because it's the easiest way to do it (trust me). You don't need to download anything, just run this command.
curl -O https://raw.githubusercontent.com/angristan/openvpn-install/master/openvpn-install.sh
chmod +x openvpn-install.sh
./openvpn-install.shThen just click enter until it asks you to input a username, choose one and it should generate an .ovpn file on the Ubuntu user (not root) home directory. You then can move this to your local machine via scp.
Connecting to VPN Server
The last part is the easiest, import the config file to your OpenVPN GUI, click connect, and you're done!

Here's whatsmyip result:

It's very fast too! around 70-80 Mbps on both download and upload, I have 100 Mbps internet connection.

Well, that's all for this guide. Thanks for reading!