Introduction
AWS Client VPN is a managed client-based VPN service that enables end-users to securely access your AWS resources. With Client VPN, you can access your resources from any location using an OpenVPN-based VPN client.
Overview
Create VPC
- VPC
a. Navigate to VPC Console
b. Create a VPC
c. Provide a name for this VPC
d. Enter an IPV4 CIDR - Subnet(s)
a. Navigate to Subnet
b. Click Create a Subnet
c. Select the VPC created above
d. Provide a subnet name
e. Enter an IPV4 CIDR that is part of the larger VPC CIDR
Authentication
There are three ways the client VPN can use authentication as the first entry to AWS:
- Active Directory – user based
- Mutual Authentication – certificate based
- SSO via SAML – user based
For this exercise, we will use the certificate based option using a Linux OS to create certificates and keys
- Create a file with the contents of the below
- Make the file executable by running chmod +x [filename]
- Run the file by running ./[filename]
#!/bin/bash
echo "Enter a folder name"
read folder
if [ -d "$folder" ]
then
echo "This folder exists"
else
mkdir ~/$folder
fi
git clone https://github.com/OpenVPN/easy-rsa.git
cd easy-rsa/easyrsa3
./easyrsa init-pki
./easyrsa build-ca nopass
./easyrsa build-server-full server nopass
./easyrsa build-client-full client1.domain.tld nopass
cp pki/ca.crt ~/$folder/
cp pki/issued/server.crt ~/$folder/
cp pki/private/server.key ~/$folder/
cp pki/issued/client1.domain.tld.crt ~/$folder
cp pki/private/client1.domain.tld.key ~/$folder/
cd ~/$folder/
exec bash
Creating Certificate and Keys
- When you run the executable, you will be asked for a name of a folder to be created which will store all the certificate files and keys
- Once you provide a folder name and hit Enter, you will be asked for the common name for the certificate. You can name this anything you desire and hit enter
- A review will be presented to you and the script will ask you to confirm by typing ‘yes’; hit enter
- Another review will be presented to you for the next set of keys and the script will ask you to confirm by typing ‘yes’; hit enter
- Once completed you will be placed in the new folder which will contain your crt and key files which will be used to import into AWS:
- ca.crt – this is your certificate chain
- client1.domain.tld.crt – this is your client certificate
- client1.domain.tld.key – this is your client private key
- server.crt – this is your server certificate
- server.key – this is your server private key
Upload Certificate and Keys
There are a few ways to upload the certificates and files to AWS:
CLI
Provided you installed AWS CLI and have configured your AWS profile for CLI you can run these commands to upload the certificate, key, and chain:
Server Certificate, Key, and Chain
aws acm import-certificate --certificate fileb://server.crt --private-key fileb://server.key --certificate-chain fileb://ca.crt
Client Certificate, Key, and Chain
aws acm import-certificate --certificate fileb://client1.domain.tld.crt --private-key fileb://client1.domain.tld.key --certificate-chain fileb://ca.crt
AWS Console
- Navigate to ACM Console
- Import a certificate
- Server Certificate, Key, and Chain
- Open the contents of the server.crt file using a text based editor
- Copy the contents into the Certificate body field of the Certificate details in the console
- Open the contents of the server.key file using a text based editor
- Copy the contents into the Certificate private key field of the Certificate details in the console
- Open the contents of the ca.crt file using a text based editor
- Copy the contents into the Certificate chain field of the Certificate details in the console
- Click on Next
- Add any Tags you desire and click on Next
- Click on Import at the Review and Import section
- Client Certificate, Key, and Chain
- Navigate back to ACM Console and click on Import a certificate
- Open the contents of the client1.domain.tld.crt file using a text based editor
- Copy the contents into the Certificate body field of the Certificate details in the console
- Open the contents of the client1.domain.tld.key file using a text based editor
- Copy the contents into the Certificate private key field of the Certificate details in the console
- Open the contents of the ca.crt file using a text based editor
- Copy the contents into the Certificate chain field of the Certificate details in the console
- Click on Next
- Add any Tags you desire and click on Next
- Click on Import at the Review and Import section
Client VPN Endpoint
- Go to VPC Console
- Client VPN endpoints
- Create client VPN endpoint
- Provide a name and description if desired
- Enter a IPv4 CIDR that is not overlapping with the target network CIDR that you have or created earlier in this exercise. This client range has to have a range between /12 and /22
- Under Server certificate ARN, click the drop down and choose the Server certificate
- Check Use mutual authentication
- Under Client certificate ARN, click the drop down and choose client certificate
- Outside of selecting Enable split-tunnel, leave the rest of the default settings, and choose Create Client VPN Endpoint
VPN Connectivity Enablement
- Navigate to VPC Console
- Client VPN Endpoints
- Choose Client VPN Endpoint (click on the blue link)
- Click Associate target network
- Select the VPC (same VPC as in the Create VPC task above) and a subnet in the same VPC
- Click on Associate target network
- You can repeat the process for other subnets if you desire
- The state of the endpoint will go to Pending-associate to Available which will result in the creation of two objects in the endpoint object:
- a route table being created to allow the VPC CIDR
- you can adjust this for your routing needs
- a security group being created with the default VPC security group applied to it
- you can adjust this for your security needs
- a route table being created to allow the VPC CIDR
VPN Network Authorization Enablement
- Navigate to VPC Console
- Client VPN Endpoints
- Choose the newly created Client VPN Endpoint
- Click Authorization rules
- Click Add authorization rule
- Enter the VPC CIDR you created earlier (same VPC as in the Create VPC task above)
- You can enable access to additional networks connected to the VPC, such as AWS services, peered VPCs, and on-premises networks. For each additional network, you must add a route to the network and configure an authorization rule to give clients access.
- Allow access to all users
- Click Add authorization rule
Client VPN Configuration File
- Navigate to VPC Console
- Client VPN Endpoints
- Click Download client Configuration
- Once downloaded, open the configuration file, and add the contents of the client certificate and client private key between respective tags <cert></cert> and <key></key> as shown in Figure 1
- Prepend a random string to the Client VPN endpoint DNS name and add it to Client VPN endpoint configuration file as shown in Figure 2
- Save the file
- You could distribute this Client VPN endpoint configuration file to others if desired
Client VPN
You can use most client VPN applications that can read the ovpn configuration file; however, for this exercise, we will use the Amazon VPN Client.
Download
The latest version for supported operating systems are found here: https://aws.amazon.com/vpn/client-vpn-download/
VPN Client Configuration
- Open AWS VPN Client
- Choose File
- Manage Profiles
- Add Profile
- Input a Display Name
- Browse and select the Client VPN Configuration file
- Click Add Profile
- Click Done
- Read to connect will have your new profile
- Click Connect
Testing
When the connectivity is established, you can see OpenVPN Statistics by:
Client VPN
- Clicking on Connection
- Show Details
AWS
- Navigate to VPC Console
- Client VPN Endpoints
- Click on the newly created endpoint
- Click on Connections
Connectivity from Client to AWS
- Test connectivity to destination AWS service (e.g., EC2) by running SSH or RDP
Conclusion
In today’s remote work environment, creating a Client VPN in your AWS environment is essential. It provides increased security, improved productivity, and is cost-effective. With the steps outlined above, you can create a Client VPN in your AWS environment and provide your remote workers with secure access to the resources they need to get their work done.