OpenVPN with DUO 2-Factor Authentication
This is a deployment guide for IT Admins who want VPN with 2-step Authentication for enhanced security. In this article we will learn how to install OpenVPN Access Server using Google Deployment Manager and integrate DUO for 2-factor Authentication.
This is a deployment guide for IT Admins who want VPN with 2-step Authentication for enhanced security. In this article, we will learn how to install OpenVPN Access Server using Google Deployment Manager and integrate DUO for 2-factor Authentication.
The following are required:
Google Deployment Manager
Ubuntu 18.04 Server
OpenVPN Access Server (BYOL)
DUO for 2-factor Authentication (BYOL)
Google Deployment Manager:
Google Deployment Manager is used to automate the whole process of Google infrastructure deployment and management.
We are using Google Deployment Manager here to reduce the deployment time as OpenVPN Access Server Image already exists in the Google Marketplace. You can skip step one if you already have OpenVPN Server running.
Google Marketplace OpenVPN Access Server image runs on Ubuntu 18.04. You can also install OpenVPN in a Windows Server but you have to do it manually as there are no images of OpenVPN on Windows Server in the Google Marketplace.
OpenVPN Access Server
OpenVPN Access Server has a license cost as it is for enterprise usage (free for up to 2 concurrent connections). We will use the OpenVPN Access Server as it is both easy to deploy and manage. The IT Admins can access the OpenVPN Admin panel from the browser.
Duo Authentication is used for 2-step Authentication. It will ask for OTP when the users try to authenticate with the OpenVPN Server. The OTP is pushed to the android/IOS devices registered with the DUO.
Deploying OpenVPN Access Server using Google Deployment Manager
1.1 Deploying OpenVPN From Google MarketPlace:
First, we will login into Google Cloud Console.
Then search for OpenVPN Access Server
1.2 Deployment Manager Deployment Details:
Click on Launch On Compute Engine to deploy the OpenVPN Access Server. You will be prompted to give the Instance a name, location, configuration, etc.
After the deployment, we will find the following window:
Here, The Admin Web Panel is given at Admin URL: https://184.108.40.206:943/admin
OpenVPN Admin Panel can be accessed by http://<instances external IP>/admin. The Admin Username and Password will be given in the deployment manager details page as shown in the above image.
Configuring OpenVPN Access Server using Admin Web Panel
2.1 Server Network Settings:
After logging in, go to Network Settings under Configuration in the left side panel. The Hostname or IP Address should be the same as the OpenVPN's External IP Address.
2.2 VPN IP Network:
Go to VPN Settings under Configuration in the left side panel. OpenVPN will assign IPs to the clients from the Dynamic IP Address Network given a range.
Scroll down in the Network Settings and you will find the Routing option. If you want your Clients Internet to flow in & out through the VPN Server, then make the following changes (this will mask your clients External IP Address with the VPN Servers External IP Address).
2.4 DNS Settings:
Scroll down in the VPN Settings and you will find the DNS Settings option. Change the settings as given below.
3.1 Creating DUO Account:
Go to the following link to create your account.
Create an account with your details. Install the DUO app on your Android or IOS devices and register it with the account. DUO will give push notifications on your registered devices when you try to log into the DUO account or for the service your DUO is configured with.
After creating the account, login with your credentials & you will receive a push notification on your Android/IOS device. Accept it to login.
3.2 Configuring DUO Account:
After you have successfully logged in, select Application from the left-hand panel.
Now click on Protect An Application Option and search for OpenVPN Access Server.
Now, click on Protect this Application and a web page will open with your DUO credentials.
You will find the following:
These credentials will be integrated into your Ubuntu18.04 Server’s DUO scripts to work with OpenVPN.
Configuring DUO in the Ubuntu 18.04 Server to work with OpenVPN
4.1 Installing Python 2.7:
Run the following in your Ubuntu 18.04 Server to install python 2.7
sudo apt update
sudo apt install build-essential checkinstall -y
sudo apt install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev -y
sudo tar xzf Python-2.7.14.tgz
sudo ./configure --enable-optimizations
sudo make install
sudo rm -rf /usr/src/Python-2.7.14*
4.2 Configuring DUO in the Ubuntu 18.04 Server:
Click this link to download the DUO Server Package.
Upload the package in the ubuntu server and extract it using the following code
tar xvzf “file-name”.tar.gz
*I have created a folder “duoas” and have extracted the DUO Server package here. Now, we will go in the extracted folder and edit “duo_openvpn_as.py” using nano.
Fill in the following with your Integration Key, Secret Key and API hostname that you have received from your DUO account (as given in Section 3.2). Save and exit.
Now, we will move the file to the OpenVPN Access Server directory and make it user executable.
mv duo_openvpn_as.py /usr/local/openvpn_as/scripts/
chmod a+x /usr/local/openvpn_as/scripts/duo_openvpn_as.py
4.3 Enabling the Post-Auth Script:
Run the following commands to set duo_openvpn_as.py as your post-auth script:
/usr/local/openvpn_as/scripts/sacli -a “admin_username” -i -k auth.module.post_auth_script --value_file=/usr/local/openvpn_as/scripts/duo_openvpn_as.py ConfigPut
Use the admin username in the above command of the OpenVPN server we received from the deployment manager. You will be asked for a Password which will be the password we received from the deployment manager.
Now, restart the service using the following command.
/usr/local/openvpn_as/scripts/sacli -a “admin_username” -i Reset
Creating Users in the OpenVPN and registering with DUO
5.1 Creating a new OpenVPN User:
Go to your OpenVPN Access Server Web Admin Panel.
Then go to the User Permission under User Management from the left panel
Fill in the new username space and click on more settings
Keep everything else default and save settings
5.2 Registering Users with DUO
Click on your OpenVPN Instance external IP
Login in with your newly created user using the username and password you have set
You will get a request to register the user with DUO
Open the given red marked link
Register the user with the Android/IOS device where you want to have the OTP/Push Notification
Using OpenVPN Connect
OpenVPN Connect will be used to connect to the OpenVPN Access Server. Here we have used “openvpn-connect-220.127.116.11_signed.msi” for windows which have worked well with DUO 2-Factor Authentication.
First, install the OpenVPN Connect in Windows.
From the Right-hand side of the taskbar click on the OpenVPN icon and click on connect. You will see the following
Enter your OpenVPN Access Server's External IP and click on continue
Users will be prompted to enter their username and password.
After that, click on Connect and the users will be asked to enter the 2-step authentication code
Open your OpenVPN Android/IOS App to fetch the OTP and enter it here to connect with the OpenVPN Access Server.
In this guide, we learned how to install OpenVPN Access Server with DUO for 2-Step Authentication. This integration can be used to enhance security, for specific developers access to cloud environments.