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:
We can now get the installation script with the following curl Command:
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:
Finally, run the script:
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:
Next, install the OpenVPN client:
OpenVPN client service
During installation, the client registers the openvpn service with systemd. Enable the service to start on boot:
Then start the service:
Check if the service is running:
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:
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!