How To Create Your Own VPN With AWS

Requirements:

  • An AWS Account (Preferably a Free Tier Eligible account if you wish to use this for free)
  • OpenVPN Client on your device

1- Log in to your account & Choose a Region

EC2 (Elastic Compute Cloud) is a AWS (Amazon Web Services) microservice which you can create virtual machines (will be called as Instance) on-demand. We will be using this service on our VPN. Before diving deeper into this, check your region. A region is the place you will put your instance. For example, you can put your instance on United States, Spain, Germany … Chose a country which is close to you (for lower latency) or a country which you wish to be seen at. This is important because you will be seen in that country when you connect to your VPN.

2- Creating the VPN

1- Go to EC2 Panel & Create Instance

Write EC2 to upper-left search bar at main panel, and click on EC2 text

On new screen, click to Launch instance button. Click again into Launch instance button

On new screen , name your instance on the box I pointed with (1). This could be anything you want. Then press Browse more AMIs button which I pointed with (2). On next screen, write OpenVPN int textbox that I pointed with (3). Then press the button I pointed with (4).

Then, there will be a list of clients. Choose the one pointed if you want a free one. This perk supports 2 devices simultaneously. If you want more, you can choose other perks too.

Press OpenVPN Access Server. On the next screen got to pricing by (6). Choose t3.micro to be eligible for free tier. As you can see, you can use this machine for 720 hour for a month for free. Then press continue. After this press Confirm Changes.

After that, you have to press create a new key pair button at the bottom of the screen. Then give it a name. Then Press Create key pair. Then your browser will ask you where to download the key. Put it on a place where you wouldn't forget because this is a critical thing which you can use it later for SSH.

Then press launch instance button. This will create your instance.

3- Configuring the VPN

Go to EC2 panel and go to Instances category(7). Click the Instance ID(8)

Now you can see your VPN’s details now. Click to button on upper-left corner “Connect”. Select SSh Client and copy the example there which I pointed. Then open a terminal(Powershell or *nix shell) on directory where is your previously downloaded key is. Paste the line you copied. Then press enter. It will ask you if you want to continue, write yes then press enter.

It will ask for a couple of things like EULA. Write yes then enter the one I pointed. Then press enter until the connection closes.

After that, we need to set up things like password to login. For this we need to connect with SSH again. But now, we need to connect as openvpnas rather than root.

Then write “sudo passwd openvpn” into terminal. It will ask a password. Write your password, this will be your admin password.

Don't be afraid that there isn't any text after “password:“ It’s OK. Just write your password, press enter and retype again. After this press enter.

And its done.

5- Going to UI

Go to your EC2 Instance settings. Copy your instance's public IP. Note that this changes every time you restart your instance.

Go to https://yourpublicip:943/admin

If you get https error just press continue.

Use openvpn as your name and password you just set.

Agree onto this

Go to VPN Settings

And press this button and make it yes. Then scroll down and press save settings.

Then press update running server

Boom. Your VPN is ready.

Now go to https://yourpublicip:943

Use same username and password and login. Download the app dedicated for your computer

Install the app. It will be ready to connect. Launch the app. Press the switch.

It will ask you username and password. Use same username and password we used before. Now you can use your VPN.

Remember to check your AWS account balance for unnecessary costs. Also make sure to stop your instance when not used.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store