Setup OpenVPN on Ubuntu via Command Line

This tutorial explains how to set up OpenVPN on Ubuntu Linux through Command Line Interface, CLI.

If you want to set up the VPN through the Network Manager on Ubuntu Desktop version, find the setup guides here.

Initial Step: It is recommended to update the outdated packages on your system by running the sudo apt update && sudo apt upgrade command.

Step #1: Switch to the root user by entering sudo -i and install OpenVPN.

apt install openvpn -y

Ubuntu OpenVPN Setup

Step #2: Enter into the OpenVPN directory and download FastestVPN’s OpenVPN server config files by running these commands.

cd /etc/openvpn
sudo wget http://support.fastestvpn.com/download/fastestvpn_ovpn/ -O fastestvpn_ovpn.zip

Ubuntu OpenVPN Setup CLI

Step #3: Unzip the downloaded files.

unzip fastestvpn_ovpn.zip

Note: If it says that “unzip command not found” then install unzip by entering apt install unzip and follow Step # 3 again.

Ubuntu OpenVPN CLI Setup

Step #4: Now copy the unzipped server files into the OpenVPN directory.

cp /etc/openvpn/tcp_files/* /etc/openvpn/ && cp /etc/openvpn/udp_files/* /etc/openvpn/

Ubuntu OpenVPN Command Line

Step #5: Enter ls so all the FastestVPN server files in the directory will be listed.
Ubuntu OpenVPN CLI

Step #6: Connect to your desired TCP or UDP VPN server by entering sudo openvpn [your desired server name]

For example:

sudo openvpn uk2-udp.ovpn

Ubuntu VPN CLI Setup
Step #7: It will require you to enter your credentials. Enter your FastestVPN Username and then Password.
Ubuntu CLI VPN Setup
Step #8: Once the logs show “Initialization sequence completed” that means the VPN connection has been established.
Ubuntu Command Line VPN Setup
To disconnect from the VPN, press Ctrl+C in the same command line session, or in another session, enter sudo killall openvpn

To connect to another server, enter into the OpenVPN directory and follow Steps # 5 to 7.