Virtual Private Network (VPN) is a great way to remotely connect to your Workstation/Server and browse internet. They add a layer of encryption to the network data transfer and protect it from snooping (MITM attacks) as well as bypass the internet restrictions imposed by governments or ISP.

OpenVPN GUI Setup Wizard

Advertisement

OpenVPN is a VPN program that allows you to setup both Server and Client machines. It is a different implementation compared to the default PPTP/L2TP/IPSec which is shipped with Windows Server 2019 and Windows 10.

In this tutorial, we will use Ubuntu 20.04 Server to install OpenVPN server via an interactive bash script. After that we will install OpenVPN-GUI client on Windows 10 and connect to the server using the client.ovpn file generated by the OpenVPN script.

OpenVPN Server/Client Requirements:

Time: 10 minutes
Client OS: Windows 10, 8, 7
Server Linux: Ubuntu 20.04 (Focal Fossa), Ubuntu 18.04.4 (Bionic Beaver) or lower till 16.04 – Arch Linux, CentOS 8, Fedora 28 and Debian 10 also supported on AMD64 / ARM64 platforms. Fresh installation is not necessary.
Root SSH access: SSH (Secured Shell) is a command-line server administration and file transfer tool that comes with Linux distributions by default.

Features of this OpenVPN Script:

  • DNS Leak Blocking
  • NAT IPv6 Support
  • Google, OpenDNS, Cloudflare DNS and many other public DNSes supported
  • IPtables Firewall Rules
  • Works on ARM64 / AMD64
  • Headless install supported

Special thanks to @angristan for this wonderful bash script.

How to Install OpenVPN Server on Ubuntu 20.04 using Script

1. Login to your Ubuntu Server Machine using SSH

Download and install the latest stable version of PuTTY client from here. It is a GUI based tool that allows you to remotely connect to your Ubuntu Server machine via Windows 10. You can skip this step if you already have physical access to your server.

• Launch PuTTY.exe 


• In the Host Name box, enter your Server IP address
• Enter the SSH port number if you have changed it. Default is Port 22
• Click [Open] after entering the host and port.
• If you are connecting for the first time, it will show you Security Alert about Host Key, click Yes.


• Now you have connected to your Server. It will ask for username [Login as:], Type ‘root‘ and press Enter.
• Then type the root password and hit enter. The password you type will not show because of security reasons but it’s being input, don’t worry.
• If the credentials are correct, you will be shown a Welcome text with System information, copyright notice, and Last Login IP address.

In the next step, you will have to type the CLI commands after the following text:

[email protected]:~#

2. Download and Install OpenVPN Server using Installation Script 

In the PuTTY SSH terminal, copy and paste the commands below one by one. CTRL+V paste will not work, just copy the text and simply Right-click once inside terminal to paste, then press Enter.

curl -O https://raw.githubusercontent.com/angristan/openvpn-install/master/openvpn-install.sh

Here we are downloading the OpenVPN Installation BASH Script using Curl command, wget can be used as well. The openvpn-install.sh will be stored in /root directory. You can use ls to list the contents of directory.

Now we make the script executable for the system root using chmod command.

chmod +x openvpn-install.sh

And then finally start the automated installation by running this:

./openvpn-install.sh

It will show a warning that your Ubuntu version might not be supported. Just typey and press Enter.

Now the script will step-by-step ask to verify the server details from you. You just have to press keep pressing Enter key as most common configuration answers are pre-entered for your convenience. You might have to enter the client name though.

The setup is complete, as shown in the video above. The OpenVPN config file is saved as “techkhoji.ovpn” in /root directory. You can use ls command to check.

Now we have to replicate/export the techkhoji.ovpn file into our client Windows 10 machine.

Enter the following command in PuTTY terminal:

cat techkhoji.ovpn

The cat command will paste the contents the .OVPN config file inline. The name of your file might be different so type the filename accordingly.

Example of the displayed contents:

client
proto udp
remote 207.246.120.239 1194
dev tun
resolv-retry infinite
nobind
persist-key
persist-tun
remote-cert-tls server
verify-x509-name server_YR2OtzcCEHXNpd1E name
auth SHA256
.
.
.
9ec1998d4d02e69a637d8b7a0fd2343
013cc96740bc782741d3fb77ef6164c3
-----END OpenVPN Static key V1-----
</tls-crypt>

Carefully highlight everything from </tls-crypt> to client by holding left-click and dragging the mouse cursor upwards. This will automatically copy the selected text to the clipboard.

Launch Notepad on your Windows 10 machine. Paste the config text that you just copied. Save the file as techkhoji.ovpn on your desktop. Make sure the file extension ends with .ovpn

3. Install OpenVPN-GUI client on Windows 10

 

Now the easiest part of whole process. Head over to the official website of OpenVPN using this link and download and install the OpenVPN-GUI using the MSI installer. It will network TAP Windows VPN adapter and ask for UAC permissions, allow it.

Launch OpenVPN GUI from Desktop. It will tell you that no config file has been found. That’s fine.

Right-click OpenVPN tray icon from taskbar and click Import File and select the techkhoji.ovpn file that we saved on desktop. It will say “File Imported Successfully

Now right-click the same tray-icon and click “Connect

OpenVPN GUI will show you a connection log process and the window will disappear after successful connection.

Now open your Web-browser and type What’s my IP in the search bar. It will show you the VPN server IP.

Congrats! You have now setup your own OpenVPN server on Ubuntu 20.04 Linux and Windows 10 client. If you face any problems with the setup, do let me know via comment section.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.