Hosting a custom VPN on an Ubuntu EC2 server.
This step-by-step guide is intended to show how to host a t2.micro Ubuntu server on EC2 and set up a secure custom VPN using angristan's script.
- Log into your AWS account and navigate to EC2.
- Use the reference to spin up a Ubuntu instance, allow SSH connections over port 22 in the instance's Security Group and create a pair of security keys for the SSH login.
- On the left panel of the EC2 menu, click Security Groups to open the settings.
- In the Security Groups settings, add an inbound rule to allow the traffic from the UDP port 1194:
- Select Custom UDP in the Type field.
- In the Port Range field, type 1194.
Note
If you ever intend to stop and restart the EC2 instance, add an Elastic IP before proceeding, so that the created VPN configuration file has a permanent IP address associated with it. Otherwise, the configuration file will need to be edited every time the EC2 instance changes the IP address.
-
Log into your new EC2 instance via SSH by following the reference.
-
In the browser, navigate to the openvpn-install repository.
-
In the SSH terminal, run the following commands from the Readme in the openvpn-install repository one by one to install OpenVPN:
sudo curl -O https://raw.githubusercontent.com/angristan/openvpn-install/master/openvpn-install.sh sudo chmod +x openvpn-install.sh sudo ./openvpn-install.sh -
Confirm the default settings for OpenVPN during the installation process.
-
After the installation is complete, an
.OVPNfile will be created in the current EC2 directory. -
Copy the
.OVPNfile to your computer.
Note
For the sake of convenience, use WinSCP or FileZilla to connect to your EC2 instance via the FTP and transfer the file to your computer.
- Launch OpenVPN on your computer, right-click the OpenVPN icon in the tray and click Import.
- Select the
.OVPNfile from your computer and click Open.
- Right-click the OpenVPN icon in the tray again, hover the mouse over the name of your VPN server and click Connect.

