Complete OpenVPN setup in AWS
Published: 2022-05-22 07:14:50

Accessing your public EC2 instances using SSH and encrypting is fine. But what about working with AWS-based data that’s not public? There are all kinds of reasons why admins keep such resources out of reach of the general public. But if you can’t get at them when you need, what good are they likely to do you?

The OpenVPN Access Server
As the name suggests, OpenVPN is an open source project, and you’re always able to download the free community edition and set things up on your own VPN server. But the OpenVPN company also provides an OpenVPN Access Server as an EC2 AMI .

What does it cost? 
If you’re only testing things out and don’t plan to access the VPN using more than two connections at a time, then the AMI itself is free.

First of all we are deploying a Linux AMI instance with disabled Auto-assign Public IP.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3npi32j64huyyk9a5d92.png)


 We will be unable to ssh into it as it has no public IP assigned (as shown in the picture below).

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lv92e5xt8juwqds8ds7a.png)

Launching an OpenVPN Access Server

OpenVPN Access Server AMIs available from the AWS Marketplace.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b92s38sh4gav830eigcm.png)
 
When it comes to instance type, We can keep it within the free tier.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/020kwouyhuinb88whim8.png)
 


 ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oe7te61jcupe1g0zynhx.png)

Choose a subnet and note for later


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hw3s90u8238l7dgidpmj.png)
 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lmbigsb804cvna3lp7tn.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zbkfzeosz6lvu5kgj0pv.png)

 Now the Security Group page is where the OpenVPN AMI settings really shine. We’re presented with a security group that opens up everything we’ll need.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3hlnq56ehfhcg37n5rjo.png)

**Note: If practical, it would normally be a good idea to tighten those rules so only requests from valid company IP address ranges are accepted, but this will be fine for short-term testing.**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lxkvpd6u72bzimjdtkpu.png)
 
Then, press Enter to all the default requirements.



 ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oz0uas5k0pm1zx5a52lk.png)
 
Note the Admin UI and Client UI.

Accessing the server
Paste the public IP address into the terminal as part of SSH command that calls the key pair set for this instance.
ssh -i KeyPairName.pem openvpnas@<PublicIPAddress>

We will need to give the openvpn user a password so We can use it to log into the web GUI.
 We do that as sudo with the passwd command.
sudo passwd openvpn

Now We are going to use a browser to log into the web GUI. We use our server’s public IP address with the secure https prefix, followed by slash and admin.
https://<PublicIPAddress>/admin


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/drwm5iwzvu49c08o1xq9.png)


 Provide the username and password as set earlier.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uiqlc4g2o985g8sth4dj.png)
 
 ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6ing7bu158efofjq3sc2.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5ju0qqobxbyghnij9eun.png)

Provide the username and password and connect .

And then ssh to Linux instance and it will responded successfully.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qg0evsa49xj5o3m3iw2l.png)