How to Setup Open VPN in Ubuntu 22.04

VPN, an acronym for “virtual private network”, is an incredible technology that protects you when surfing the internet. Originally developed for large corporations, VPN services are available for everyone. Among all the VPN service providers, OpenVPN is a unique name.OpenVPN allows you create your own VPN with the help of their open-source program. The software can work with both TCP and UDP transmissions. The VPN tunnels are secured OpenVPN protocol that uses SSL/TLS authentication, certificates, credentials, MAC address lock (optional), and more.In this guide, we will demonstrate on how to set up the OpenVPN in Ubuntu 22.04.


To perform the steps that we demonstrate in this guide, you will need the following components:

OpenVPN Server Configuration

Manual installation and configuration of an OpenVPN server is a tedious work. To streamline the process, we will use a third-party installer script from GitHub: angristan/openvpn-install. The script supports a wide range of operating systems and architectures.

First, make sure that curl is installed:

$ sudo apt install curl -y

We can now grab the installation script with the following curl command:

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

Next, we have to change the file permission so that we can execute the script. Use the following command to flag the script as an executable file:

$ chmod +x openvpn-install.sh

Finally, run the script:

$ sudo bash openvpn-install.sh

The script will ask for various info about the server, what features you want to enable/disable, and such. Then, it installs the necessary packages.

Once the installation process finishes, the script generates a client configuration file under the current working directory. This file is important to configure the clients that connect to this particular OpenVPN server.

If you’re an advanced user or system admin and require a finer control over the installation process, check out the manual setup process of OpenVPN server in Ubuntu 22.04.

OpenVPN Client Configuration

OpenVPN Client Package Installation

We now work on the client machine. The OpenVPN client software is directly available from the official Ubuntu repos.

First, update the APT package database:

$ sudo apt update

Next, install the OpenVPN client:

$ sudo apt install openvpn

OpenVPN Client Service

Upon installation, the client will register the openvpn service with systemd. Enable the service so that it starts at boot:

$ sudo systemctl enable openvpn

Then, start the service:

$ sudo systemctl start openvpn

Check if the service is up and running:

$ sudo systemctl status openvpn

Copying the OpenVPN Configuration File

We obtained an OpenVPN client configuration file from the server configuration. In this section, we will grab it from the server.

There are multiple ways that we can grab it from the server. One common method is to use the scp command. It’s basically the cp command but over SSH.

Copy the OpenVPN configuration file from the server to the current directory:

$ scp <username>@<server_ip>:/path/to/config.ovpn .

Configuring the VPN

With the configuration file, we can now use the Settings app to configure the VPN. Start the app from Activities.

From the Network tab, click the “+” icon after the VPN section.

From the new pop-up window, select “Import from file“.

Browse for the OpenVPN configuration file.

You’ll be presented with a window that contains various info about the VPN. Click “Add” to finalize the process.

Go back to the Network tab again. There should be a VPN entry under the VPN section.


In this guide, we demonstrated the installation and configuration of OpenVPN in Ubuntu. We showcased how to configure both an OpenVPN server and a client. Note that multiple clients can connect to the OpenVPN server with the configuration file.

Other than OpenVPN, there are also other methods of creating a VPN. For example, sshuttle can create a VPN over SSH. You can also configure a SOCKS proxy that acts as a VPN.

If you are interested in exposing your local web app to the internet, you can do so with the help of a reverse proxy like Nginx.

Happy computing!

About the author

Sidratul Muntaha

Student of CSE. I love Linux and playing with tech and gadgets. I use both Ubuntu and Linux Mint.