DEV Community

Cover image for Install VPN (OpenVPN) Server on AWS EC2 Instance (Ubuntu)
ピメン.ヴィ.ブリタニア
ピメン.ヴィ.ブリタニア

Posted on

Install VPN (OpenVPN) Server on AWS EC2 Instance (Ubuntu)

I think you can use ec2 free tier to create your own vpn server instead of buying or using free limited vpn, hm...

First, you need to login to your aws console and find ec2 service, then create a new instance (launch intance):
***Image description

  • Select free tier instance type
  • Generate your own key-pair (required to connect with ssh)
  • On network setting click edit
    • Click add security group rule then add new rule for custom UDP with port range = 1194 and source type from anywhere
    • Image description
    • Image description
  • Then on Advanced detail setting scroll to bottom and you will find User data field, and fill with:
#! /bin/bash
apt-get update
curl -O https://raw.githubusercontent.com/angristan/openvpn-install/master/openvpn-install.sh

chmod +x openvpn-install.sh

APPROVE_INSTALL=y ENDPOINT=$(curl -4 ifconfig.co) APPROVE_IP=y IPV6_SUPPORT=n PORT_CHOICE=1 PROTOCOL_CHOICE=1 DNS=1 COMPRESSION_ENABLED=n  CUSTOMIZE_ENC=n CLIENT=david PASS=1 ./openvpn-install.sh 
Enter fullscreen mode Exit fullscreen mode
  • Then Launch instance.

After instance created, you can login into instance with your instance key-pair.pem, then you can install openvpn-install to generate your account/configuration file (.ovpn).

When installed, you can generate file by running:

sudo ./openvpn-install.sh
Enter fullscreen mode Exit fullscreen mode

You can copy the configuration file into your local machine, and install OpenVpn client (windows) or Tunnelblick (MacOs), then CONNECT!!

Image description

Top comments (0)