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

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

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

Okay