How to Setup OpenVPN Server in Ubuntu 22.04 [The Easy Way]

Last updated: October 7, 2022 — Leave a comment

This simple tutorial shows how to easily setup OpenVPN in your Ubuntu 20.04 | 22.04 server and connect remotely in Windows or Linux with GNOME.

My PPTP and IKEv2 VPN server refused to work recently due to the Great Firewall (maybe). So I decided to setup OpenVPN in my Ubuntu VPS as a workaround.

DigitalOcean has a step by step setup guide, but it’s really long and complicated for beginners. Thankfully, there’s a free open-source script make things as easy as few commands.

Step 1: Install OpenVPN

As mentioned, there’s a script in the github to make things easy. It automatically detects your system, environment variable, IP address, and setup OpenVPN and firewall.

The script is totally safe in my own opinion, and you can view the code by yourself. Though, there’s always disclaimer that use it as your own risk!

1. First, connect to your Ubuntu/Debian server either via SSH or other method that you favorite. Then grab the script by wget:

wget -O

In case wget command does not exist, install via sudo apt install wget.

2. After downloaded the script, add executable permission via command:

chmod u+x

3. Finally, run the script:

sudo bash

It will ask you a few questions to confirm IP address if your server is running behind NAT, choose UDP or TCP, set which port to listen to, and select a NDS server. For lazy men, it’s OK hit Enter to use default for all previous questions.

But, you need to finally type a name for the client. It will create a .ovpn file with the name you just typed.

Default options are usually OK except the client name

After answering all the questions, hit any key to get start. It will do all the remained things, and generate a .ovpn file.

Step 2: Copy & paste the .ovpn to client machine

As the screenshot above shows you, it generates the .opvn file in /root directory in my case. In case you logged in via non-root user, copy the file to user’s home via:

sudo mv /root var jetpackLazyImagesL10n = {"loading_warning":"Images are still loading. Please cancel your print and try again."};