Hackers and snooping third parties can potentially grab our private data, as in the case of using unprotected public networks. The Virtual Private Network (VPN) is a superb way of protecting Linux users. Benefits of using a VPN include: stopping ISP tracking, anonymity, access to geo-locked content, ultrafast P2P file sharing, mechanism stopping during internet failure, etc.
In contrast to other VPN protocols like PPTP, OpenVPN solutions can give strong encryption and stability even if connection problems occur.
A simple setup of OpenVPN can be done using a command line or network manager.
Let’s get started.
OpenVPN setup using Command Line
This command line guide might also work for older/newer Linux versions. If it does not work, then it is recommended to look elsewhere.
- To open the command line, click on the menu and write “Terminal.”
In the terminal, type:
- for Ubuntu and Debian
sudo apt-get install openvpn
- for Fedora and Cent
sudo yum install openvpn
sudo dnf install openvpn
- The system may ask for your username and password (VPN supplier/client credentials).
- Navigate to the OpenVPN configuration directory.
- Download the OpenVPN configuration files from the supplier/client to your home directory.
sudo wget https://”vpn supplier…/(config file name)”.zip
- Extract the files to a known location.
sudo unzip “(config file name)”.zip
- Move all files to /etc/openvpn/.
sudo cp /etc/openvpn/”(config. file name)”/* /etc/openvpn/
- Re-name the .ovpn configuration files to .conf.
rename -v ‘s/\.ovpn/\.conf/’ *.ovpn
- To see a list of all available servers, enter the following:
- You shall connect to the server as suggested on the supplier/client website.
OpenVPN will ask you for your credentials. Enter your VPN supplier login details.
Start OpenVPN with the chosen configuration.
sudo openvpn (file name)
- For practical reasons, you can store your credentials, allowing you to connect to the server
- without repeatedly entering them. Create a file called “pass” in a known location. This known
location might be the same “supplier-openvpn-config/” from the previous steps.
- Press Ctrl+X to save the file and exit.
sudo nano /etc/resolv.conf
- To close the VPN connection to the VPN Server, type CTRL+C in the terminal.
OpenVPN setup using Network Manager
- First, check if the Network Manager Plugin for OpenVPN is installed.
If not, open the terminal on the menu. Write “Terminal” and apply the following command:
sudo apt-get install network-manager-openvpn
If that fails, please also enter the information below.
sudo apt-get install network-manager-openvpn-gnome
- Download the OpenVPN Configuration file package.
- Extract it into the selected directory.
- At the top right of the menu bar, click on the Network Manager icon.
- Depending on the Linux version, from the drop-down menu, you will find a button such as «Network
Connections», «Edit Connections», «VPN Settings».
- The configuration window will open.
- Click the button «Add» to choose a VPN connection.
- Select an option like «Import from file» or «Import VPN configuration»
- Choose a file (server) from the list you want to connect to
- All VPN settings (connection name, username, password, certificates, keys) may be imported. If not, select the following:
- Connection Name: (generally equal to the chosen server)
- Username: (equal you signed up for the VPN supplier)
- Password: (equal you signed up for the VPN supplier)
- User certificate: select “(supplier/client).crt”
- CA certificate: select “ca.crt”
- Private Key: “(supplier/client).key”
- Press Save. VPN connections are now available on your Network Manager connections list.
- To connect to the VPN you added, go to the Network Manager icon, find the VPN added, and slide the button to turn it green.