ProPrivacy is reader supported and sometimes receives a commission when you make purchases using links on this site.

How to setup OpenVPN on Linux

Are you a Linux user who wants to connect to VPN servers using the secure OpenVPN encryption protocol? It's possible that you'll need to set up the VPN connection manually to do so, using the command-line interface (CLI).

Very few VPN providers have a VPN client with a graphical user interface (GUI) for Linux distros, and even fewer provide OpenVPN in those custom clients. If you want to take the easiest possible route for setting up a VPN on Linux, then picking a Linux VPN with a GUI client is your best bet.

If you already have a VPN subscription and want to set up the VPN on Linux, the good news is that plenty of providers offer the .ovpn configuration files for their servers. As a result, you can set up an OpenVPN connection manually by installing the official third-party OpenVPN client.

Unfortunately, Linux does not come with OpenVPN pre-installed – but you can easily install it yourself to begin manually connecting using these .ovpn files. In this guide, we will explain how to set up OpenVPN on different Linux distros (Ubuntu, Debian, and Fedora).

Check out our top 10 Linux VPN recommendations!

How to set up OpenVPN on Linux

Installing and setting up OpenVPN on Linux can be somewhat tricky, but it differs slightly from distro to distro. To help you out, we've included instructions for installing and setting up OpenVPN with a VPN provider's config files.

Please bear in mind that you'll need to have a VPN subscription in order to download the config files from the provider's website  – and that you'll need to do this before setting up the OpenVPN connection manually on your system.

It is also worth noting that although the guides below will explain how to install and set up OpenVPN on Linux distros using config files, it's likely that your VPN provider has a similar guide that's more specific to its service.

If you have any trouble using the general guides below, we suggest you contact your VPN so that you can see their provider-specific setup instructions. 

Setup OpenVPN on Ubuntu

  1. Open up a terminal window
  2. Enter this command:sudo su
  3. Download components:apt-get install openvpn
  4. At this stage, you may be asked to enter your password to confirm your identity.
  5. Add the .ovpn config file that you got from your VPN provider by extracting the file and placing it in the preferred location (which is /etc/openvpn/) using the command:sudo unzip~/Downloads/US-East.zip-d /etc/openvpn/(remember the file name that is in bold is the file that you downloaded from your VPN provider and may be named differently. Thus, be sure to write the name of the zip file that you downloaded from your VPN provider in place of the bolded words).
  6. Now you can connect using that configuration file:sudo openvpn <config.ovpn>(where <config.ovpn> is the config file name of the server that you downloaded from your VPN provider).
  7. At this stage, you'll need to input your credentials. Enter the Auth Username and Auth Password when asked (you'll need to have acquired these from your VPN provider).
  8. The OpenVPN connection should now establish, and you will see confirmation with the words: Initialization Sequence Completed.

Setup OpenVPN on Fedora

  1. Open up a terminal window
  2. Download the components: $ sudo dnf install openvpn
  3. At this stage, you may be asked to enter your password to confirm your identity. Enter Y and press enter to confirm.
  4. To configure DNS enter the following: 

    $ sudo cp /usr/share/doc/openvpn/contrib/pull-resolv-conf/client.{up,down} /etc/openvpn/

    $ sudo chmod +x /etc/openvpn/client.{up,down}

    $ sudo sed -i.e. 's|\bresolvconf\b|ignore-&|' /etc/openvpn/client.{up,down}

  5. Now launch OpenVPN: $ sudo openvpn --config /[path to file]/my_expressvpn_[server location].ovpn --script-security 2 --up /etc/openvpn/client.up --down /etc/openvpn/client.down
    Note: The example above uses an ExpressVPN config file. However, you will need to replace [path to file] with the path to where you downloaded your VPN's configuration file. You will also need to alter the [server location] with the location shown in the filename that you downloaded from your provider. And you will need to change the filename itself (everything that appears before .ovpn) to be that of the file that you downloaded from your VPN provider rather than the example file used above.
  6. At this stage, you'll need to input your credentials. Enter the Auth Username and Auth Password (you will need to have got these from your VPN provider when you downloaded the config file).
  7. The OpenVPN connection should now establish, and you will receive confirmation with the words: Initialization Sequence Completed.

Setup OpenVPN on Debian

  1. Open up a terminal window
  2. Run as superuser: su
  3. Download the components: apt-get update && apt-get upgrade && apt-get install curl openvpn
  4. At this stage, you may be asked to enter your password to confirm your identity. Enter Y and press enter to confirm.
  5. To launch OpenVPN, enter the following: $ sudo openvpn --config /[path to file]/my_expressvpn_[server location].ovpn --script-security 2 --up /etc/openvpn/update-resolv-conf --down /etc/openvpn/update-resolv-conf

    Note:
    The example above uses an ExpressVPN config file. However, you will need to replace [path to file] with the path to where you downloaded your VPN's configuration file. You will also need to alter the [server location] with the location shown in the filename that you downloaded from your provider. And you will need to change the filename itself (everything that appears before .ovpn) to be that of the file that you downloaded from your VPN provider rather than the example file used above.
  6. At this stage, you'll need to input your credentials. Enter the Auth Username and Auth Password (you will need to have got these from your VPN provider when you downloaded the config file).
  7. The OpenVPN connection should now establish, and you will receive confirmation with the words: Initialization Sequence Completed.

Why use OpenVPN for Linux? 

OpenVPN is a popular encryption protocol that is implemented by the vast majority of market-leading VPNs. These services provide OpenVPN because it's a trusted encryption algorithm that can provide strong data privacy and security when implemented correctly.

This is largely thanks to thorough audits, and OpenVPN is also known to be secure against penetration when implemented above the minimum standards recommended by OpenVPN devs. And, even if these recommendations are exceeded, data remains protected against eavesdropping while in the VPN tunnel.

OpenVPN leverages the OpenSSL encryption library and the TLS protocol, as well as SSL/TLS for key exchange. It is an efficient algorithm capable of traversing network address translators (NATs) and firewalls.

Using a Linux VPN client with OpenVPN

Unfortunately, only a handful of VPN services offer full Graphic User Interface (GUI) apps for Linux. This can feel a little unfair, especially given how accessible VPN apps are for Windows and Mac users, but Linux loyalists do have some options. Using a VPN with a GUI client has some serious advantages over CLI and manual connections, too.

Linux VPNs typically come stocked with security-enhancing features, like DNS leak protection, that are vital to anyone wanting to avoid third party tracking. A kill-switch is another important piece of privacy boosting kit that's offered by most VPN providers – and is particularly important for aspiring torrenters. Similarly, the very best Linux VPNs come with a huge fleet of servers dotted across the globe, making it easy to pick a nearby location and avoid sluggish connection speeds.

It's also worth noting that VPN services with full Linux clients are much easier to use than their CLI counterparts! So, if you're more comfortable with a fully-featured app than a command prompt, you might want to check out our top Linux VPN recommendations as listed below:

From $2.19/bb_table.month

The best VPN for Linux. It has dedicated clients for a number of Linux distros, as well as a sleek GUI and OpenVPN encryption. Also offers a 30-day money-back guarantee.

ProPrivacy TrustScore:
10 out of 10
Server locations
84
Simultaneous connections
10
Free trial
No

From $5.50/bb_table.month

The best privacy-minded VPN for Linux. Offers a kill-switch, multiple simultaneous connections, and a full GUI Linux VPN client. Users can pay with cash, and enjoy a 30-day money-back guarantee.

ProPrivacy TrustScore:
9.9 out of 10
Server locations
36
Simultaneous connections
5
Free trial
No

From $3.23/bb_table.month

The best advanced VPN for Linux. A great pick for VPN veterans, it protects against leaks and can defeat VPN censorship, and offers a complete GUI Linux client as well as a 30-day money-back guarantee.

ProPrivacy TrustScore:
9.8 out of 10
Server locations
21
Simultaneous connections
5

From $0.00/bb_table.month

The best user-friendly VPN for Linux. With a sleek Linux GUI and a vast array of servers, users will have no trouble unblocking in-demand sites and services. With a 30-day money-back guarantee.

ProPrivacy TrustScore:
9.7 out of 10
Simultaneous connections
10
Server locations
61
Free trial
Yes

From $6.67/bb_table.month

The best feature-rich VPN for Linux. A command-line-only client compatible with multiple Linux distros, and superb connection speeds ideal for streaming, gaming, or downloading. Also offers a 30-day money-back guarantee.

ProPrivacy TrustScore:
9.6 out of 10
Simultaneous connections
5
Free trial
No
Server locations
160

Written by: Ray Walsh

Digital privacy expert with 5 years experience testing and reviewing VPNs. He's been quoted in The Express, The Times, The Washington Post, The Register, CNET & many more. 

2 Comments

Petr Stepanek
on December 3, 2021
Reply
Thank You for perfect article. In the code for startin OpenVpn service on Fedora You have small error: In the end of the line must be: --down /etc/openvpn/client.down All line look like: sudo openvpn --config /[path to file]/my_expressvpn_[server location].ovpn --script-security 2 --up /etc/openvpn/client.up --down /etc/openvpn/client.down
https://cdn.proprivacy.com/storage/images/2021/08/andreas-squarejpg-avatar_image-small.png
Andreas Theodorou replied to Petr Stepanek
on December 6, 2021
Reply
Hi Petr, thanks for pointing this out, we've just updated the page!
Got Something to Say?

Write Your Own Comment

Your comment has been sent to the queue. It will appear shortly.

Your comment has been sent to the queue. It will appear shortly.

Your comment has been sent to the queue. It will appear shortly.

  Your comment has been sent to the queue. It will appear shortly.

We recommend you check out one of these alternatives:

The fastest VPN we test, unblocks everything, with amazing service all round

Large brand with very good value, and a cheap price

One of the largest VPNs, voted best VPN by Reddit

One of the cheapest VPNs out there, but an incredibly good service