DEV Community

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

Posted on

10 3

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

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay