Setting up an OpenVPN server on Ubuntu can be a challenging task, especially if you do not make the necessary preparations in advance. In this tutorial, I will guide you through the steps required to create an OpenVPN user and configure the basic firewall. With these measures, your new Linux system will be optimally prepared for the OpenVPN project.

Key insights

  • Creating an OpenVPN user with appropriate permissions
  • Configuring the UFW firewall for OpenVPN access

Step-by-step guide

1. Logging into the server

First, log into your server. Whether you are using VirtualBox or an online server like Digital Ocean does not matter. For me, it is Digital Ocean, and the server is not yet configured. Here, you start by entering your login credentials.

2. Creating an OpenVPN user

To create a new OpenVPN user, enter the command sudo openvpn. At this step, you should assign a name and a password to the user. Make sure the password contains both uppercase and lowercase letters. In this case, I have already prepared a username.

3. Confirming user information

After entering the username and password, a prompt will appear to confirm the information. You need to confirm with “J” or “Y,” depending on whether your operating system is configured in German or English.

4. Setting permissions for the user

In the next step, we need the appropriate permissions for the OpenVPN user. Use the usermod command with the -aG options to add the user to the Sudo group so they can execute commands as an administrator. You will need to enter the password for your user here.

5. Firewall configuration with UFW

Now let’s talk about the basic firewall configuration. Use the command sudo ufw to start the firewall. Then, list the available apps with app list. You should see “OpenSSH,” which is important for your SSH connection.

6. Setting up UFW rules

To ensure that you have access to the server services, allow OpenSSH with the command allow OpenSSH. This will ensure that the SSH connections are not blocked. After entering, the rule will be updated.

7. Activating UFW

To activate UFW, enter sudo ufw enable. Note that incorrect configuration can disrupt your SSH connection, so it's important that you perform all steps carefully. When activating, you will be asked if you really want to make the changes.

8. Checking firewall status

Finally, you can check the status of your firewall to see if the rules are active and whether objects like OpenSSH are allowed. You can do this with the command sudo ufw status. The output will show you the active rules and that all other connections are blocked.

Summary – Setting up OpenVPN user and firewall on Ubuntu

In this guide, you learned how to create an OpenVPN user on an Ubuntu server and configure the basic firewall. These steps are essential for operating your OpenVPN server and optimally prepare the system for future settings.

Frequently asked questions

How do I create an OpenVPN user?Use the command sudo openvpn and enter the username and password.

What is UFW and what do I need it for?UFW (Uncomplicated Firewall) is a tool for managing the firewall on Ubuntu that allows simple rules.

How do I activate UFW?Use the command sudo ufw enable to activate the firewall and set the blocks.

What happens if I configure it incorrectly?An incorrect configuration can disrupt your SSH connection, so you should work carefully.