How to set up a VPN with Linux

Tech Insights in Your InboxSubscribe to our free newsletter and never miss out on what's happening in the tech world. Learn Tech Today, Lead Tomorrow.

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.

  1. 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

or

sudo dnf install openvpn

  1. The system may ask for your username and password (VPN supplier/client credentials).
  2. Navigate to the OpenVPN configuration directory.

cd /etc/openvpn

  1. Download the OpenVPN configuration files from the supplier/client to your home directory.

sudo wget https://”vpn supplier…/(config file name)”.zip

  1. Extract the files to a known location.

sudo unzip “(config file name)”.zip

  1. Move all files to /etc/openvpn/.

sudo cp /etc/openvpn/”(config. file name)”/* /etc/openvpn/

  1. Re-name the .ovpn configuration files to .conf.

rename -v ‘s/\.ovpn/\.conf/’ *.ovpn

  1. To see a list of all available servers, enter the following:

ls -al

  1. 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)

  1. For practical reasons, you can store your credentials, allowing you to connect to the server
  2. 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.

nano /home/user/”supplier”-openvpn-config/pass

username

password

  1. Press Ctrl+X to save the file and exit.

sudo nano /etc/resolv.conf

  1. To close the VPN connection to the VPN Server, type CTRL+C in the terminal.

OpenVPN setup using Network Manager

  1. 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

  1. Download the OpenVPN Configuration file package.
  2. Extract it into the selected directory.
  3. At the top right of the menu bar, click on the Network Manager icon.
  4. Depending on the Linux version, from the drop-down menu, you will find a button such as «Network

Connections», «Edit Connections», «VPN Settings».

  1. The configuration window will open.
  2. Click the button «Add» to choose a VPN connection.
  3. Select an option like «Import from file» or «Import VPN configuration»
  4. Choose a file (server) from the list you want to connect to
  5. 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”
  1. Press Save. VPN connections are now available on your Network Manager connections list.
  2. 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.
Be sure to follow us

Join our newsletter

Subscribe to our newsletter and never miss out on what's happening in the tech world. It's that simple.
subsc
Be sure to follow us

Join our newsletter

Subscribe to our newsletter and never miss out on what's happening in the tech world. It's that simple.
subsc