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

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

  1. Notice the system may ask 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 list of all available servers, enter the following:

ls -al

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

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

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



  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 as below.

sudo apt-get install network-manager-openvpn-gnome

  1. Download the OpenVPN Configuration file package.
  2. Extract it into a 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 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. Now, you choose a file (server) from the list you want to connect.
  5. 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”
  1. Press Save. The VPN connection is now available in 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.

🚀 Trusted source for tech since 2012