Installing OpenVPN server on Ubuntu server

I searched the internet a lot before a friend recommended this script, with which you can easily set up your own secure OpenVPN server.
What you’ll need:
- PuTTY or any other SSH client capable of establishing a connection
- A server/VPS running Ubuntu 18.04 or 19.04
- For VPS: enabled TUN/TAP modules
- Minimal command-line knowledge
First, you need to download the script, which you can do by running the following command:
curl -O https://raw.githubusercontent.com/angristan/openvpn-install/master/openvpn-install.sh && chmod +x openvpn-install.sh
Run the script with root privileges:
./openvpn-install.sh
- The script automatically detects your server’s public IP address, but if multiple IPs are assigned to your server, you can overwrite this.
- You can set the port if the default 1194 doesn’t suit you.
- DNS server settings (option 3 is set by default, but you can choose as needed)
- Then you need to enter the name of the first user, but don’t worry, you can add more users to the server later.
- You can set up password protection.
Once that’s done, the output will show you where the config file was generated (usually in the user’s home directory), named “thenameyouentered.ovpn”. Download this via SFTP or FTP.
If you encounter an error where the script can’t find the /etc/openvpn/easy-rsa/pki/.rnd file, then uninstall openvpn by running the script and selecting option 3, then edit the script.
Find the /easyrsa init-pki section, and insert this before it: /easyrsa –batch build-ca nopass
If everything went well, it should look like this:
./easyrsa --batch build-ca nopass # Create the PKI, set up the CA, the DH params and the server certificate ./easyrsa init-pki
Then reinstall, and it should work without errors now.
To connect, you’ll need the OpenVPN GUI, which you can download from here.
OpenVPN must be run as administrator, which you can do by right-clicking and selecting “Run as administrator,” or by setting it in the properties to always start that way (this is preferred).
Once that’s done:
- For 64-bit installation, navigate to: C:\Program Files\OpenVPN\config
- For 32-bit installation, navigate to: C:\Program Files (x86)\OpenVPN\config
Copy the *.ovpn file here, then start the OpenVPN GUI and connect by right-clicking on it.
I hope I could help; if you have any problems or questions, feel free to ask in the comments.