news
Public API for Service Management

How to Install OpenVPN Server on Ubuntu 20.04

JH
Joe Harris
December 15, 2020

In this tutorial, we will install the OpenVPN server on Ubuntu 20.04. To do this, you need to log in as the root user. You also must know the public IP of the server with which clients will establish a secure VPN channel.

OpenVPN installation and configuration

We will use the script to install and configure all the necessary packages to start the OpenVPN server. All you have to do is provide it with the correct public IP address of your server. Let’s download it.

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

Make it executable.

chmod +x openvpn-install.sh

Now run the script.

./openvpn-install.sh

You will be asked to confirm some parameters that have optimal values by default. The only thing that is really worth checking is the public IP of the server. Other parameters should only be changed if you understand what you are doing and why.

OpenVPN installation settings
Screen 1. OpenVPN installation settings.

In the last step, you need to set the client name and choose whether to protect the configuration with a password or not. For security reasons, it’s better to set a password.

When the process is over, you can check whether the OpenVPN server is listening for incoming connections.

ss -tupln | grep openvpn

OpenVPN server is listening for incoming connections
Screen 2. OpenVPN server is listening for incoming connections.

OpenVPN client connection

We will use another Ubuntu machine to show the client connection process. You can configure any Linux system in this way or download the Windows client from the OpenVPN web site: https://openvpn.net/community-downloads/

At the end of the OpenVPN server configuration process, you will see a message stating that the client configuration has been created and the path to it is specified. Download it to the client.

scp user@vpn-server:/path/to/configuration.ovpn /home/user

Install the OpenVPN client.

sudo apt install openvpn

Now start the client and specify the path to the configuration downloaded from the server.

openvpn --config /path/to/configuration.ovpn

The next line shows that the connection was established successfully.

Wed Dec 9 19:59:58 2020 Initialization Sequence Completed

Add more OpenVPN clients or delete one

To add or remove clients on the server or delete OpenVPN, run the script again and select the appropriate option.

./openvpn-install.sh

Output:

What do you want to do?
1) Add a new user
2) Revoke existing user
3) Remove OpenVPN
4) Exit
Select an option [1-4]:

Start Your Cloud Journey Migration made simplified. Take the first step right now.
We use cookies to provide our services and for analytics and marketing. To find out more about our use of cookies, please see our Privacy Policy. By continuing to browse our website, you agree to our use of cookies.