Setup Openvpn In 2 minutes
Setting Up OpenVPN Server on Ubuntu and Creating Users
OpenVPN is an open-source and free software application that allows secure virtual private network (VPN) connections over the internet. With an OpenVPN server, you can access your home or office network from anywhere in the world as if you were physically present there. In this tutorial, we will guide you through the process of setting up an OpenVPN server on Ubuntu using a bash script.
Prerequisites:
- A Linux machine with Docker installed.
- Basic knowledge of Linux commands.
- Terminal or SSH access to the Linux machine.
- Sudo access to the Linux machine.
OpenVPN Setup on Ubuntu Server:
- First, download the bash script from the GitLab repository by running the following command in the terminal:
- Navigate to the 'openvpn-in-linux' folder and replace 'VPN.SERVERNAME.COM' with your domain name or server IP. After making the necessary changes, make the bash script executable by running the following command:
- Run the bash script to set up the OpenVPN server on Ubuntu by executing the following command:
git clone https://gitlab.com/Sushmii/openvpn-in-linux.git
Note: Use sudo su
to execute all commands without encountering errors.
chmod +x openvpn-setup.sh
./openvpn-setup.sh
Creating OpenVPN Users:
- To create an OpenVPN user, ensure that the 'create-or-delete-users.sh' file is executable. You can achieve this by running the following command:
- Now, you can create a new OpenVPN user on Ubuntu by executing the following command:
chmod +x create-or-delete-users.sh
./create-or-delete-users.sh
This bash script allows the user to add or remove users from an OpenVPN server. If the user selects "add," the script prompts for a new username, creates an OpenVPN user with Docker, and generates necessary configuration files. If "remove" is chosen, the script asks for the username, revokes the user's certificate, and removes associated files. If an invalid action is entered, it displays an error message prompting the user to choose "add" or "remove." The script will also establish a new directory for the user's files and generate the client configuration for the OpenVPN Ubuntu client.
You can find all the commands and scripts on my GitLab repository: https://gitlab.com/Sushmii/openvpn-in-linux
Conclusion:
In this tutorial, we have successfully set up an OpenVPN server on Ubuntu using a bash script. Moreover, we have learned how to create an OpenVPN user for the Ubuntu server. By implementing this setup, you can securely access your home or office network from any location worldwide, just as if you were physically present there. Additionally, the process includes configuring an Ubuntu OpenVPN server with a GUI for easier management.
If you Liked my blog ,Follow on LinkedIn
People who read this also read


