Hackers and snooping third parties can potentially grab our private data, as in the case of using unprotected public networks. Virtual Private Network (VPN) is a superb way of protecting Linux users. Benefits of using VPN include: stop ISP tracking, anonymity, access to geo-locked content, ultrafast P2P file sharing, mechanism stop during internet failure, etc.
OpenVPN solutions, in contrast to other VPN protocols like PPTP, can give strong encryption and stability even if connection problems occur.
A simple setup of OpenVPN can be done by using a command line or network manager.
Let’s get started.
See also: Best Linux web hosting services
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.
- In order to open the command line, click on the menu button 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
- Notice the system may ask 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 list of all available servers, enter the following:
- You shall connect to the server suggested to you at the supplier/client website.
OpenVPN will ask you for credentials. Enter your VPN supplier login details.
Start OpenVPN with a chosen configuration.
sudo openvpn (file name)
- For a practical reason, you can store your credentials which allows you to connect server
without entering them repeatedly. 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 as below.
sudo apt-get install network-manager-openvpn-gnome
- Download the OpenVPN Configuration file package.
- Extract it into a 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 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» .
- Now, you choose a file (server) from the list you want to connect.
- All the VPN settings (connection name, username, password, certificates, key) may be imported. If not, select as follows:
- Connection name: (generally is equal to the chosen server)
- Username: (equal you signed up the VPN supplier)
- Password: (equal you signed up the VPN supplier)
- User certificate: select “(supplier/client).crt”
- CA certificate: select “ca.crt”
- Private Key: “(supplier/client).key”
- Press Save. The VPN connection is now available in 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.