How to set up Open VPN in Ubuntu 22.04

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


In order to complete the steps that we will demonstrate in this guide, you will need the following components:

  • A properly configured Ubuntu system.
  • A properly configured UbuntuCloud-Server (for setting up the OpenVPN server).
  • Access for a non-root user with sudo Authorization on both systems. Learn more about administration sudo Privilege.

OpenVPN server configuration

Installing and configuring an OpenVPN server manually is a tedious job. To streamline the process, we use a third-party installer script from GitHub: angristan/openvpn-install. The script supports a variety of operating systems and architectures.

Make sure of that first curl Is installed:

$ sudo suitable To install curl -y

We can now get the installation script with the following curl Command:

$ curl -O

Next we need to change the file permission so we can run the script. Use the following command to mark the script as an executable:

$ chmod +x

Finally, run the script:

$ sudo bash

The script asks for various information about the server, what features you want to enable/disable and such. The required packages are then installed.

Once the installation process is complete, the script will generate a client configuration file in the current working directory. This file is important to configure the clients connecting to this particular OpenVPN server.

If you are an advanced user or system admin and need more granular control over the installation process, check out the OpenVPN server manual setup process in Ubuntu 22.04.

OpenVPN client configuration

Installation of the OpenVPN client package

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

First update the APT package database:

$ sudo appropriate update

Next, install the OpenVPN client:

$ sudo suitable To install openvpn

OpenVPN client service

During installation, the client registers the openvpn service with systemd. Enable the service to start on boot:

$ sudo systemctl enable openvpn

Then start the service:

$ sudo systemctl start openvpn

Check if the service is running:

$ sudo systemctl status openvpn

Copy the OpenVPN configuration file

We got an OpenVPN client configuration file from the server configuration. In this section we will get it from the server.

There are several ways we can get it from the server. A 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 .

Configure VPN

With the configuration file we can now use the settings App to configure the VPN. Start the app from activities.

Of the network On the “+” tab, click the “+” symbol after ” VPN Section.

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

Look for the OpenVPN configuration file.

You will be presented with a window containing various information about the VPN. click”Add to“, to complete the process.

Return to the Network tab again. There should be one VPN entry under the VPN Section.


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

Besides OpenVPN, there are other methods to create a VPN. To the example, sshuttle can create a VPN over SSH. You can also configure a SOCKS proxy to act as a VPN.

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

Have fun calculating!

Related Posts