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).
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
- Open up a terminal window
- Enter this command: sudo su
- Download components: apt-get install openvpn
- At this stage, you may be asked to enter your password to confirm your identity.
- 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 fromyour VPN provider in place of the bolded words).
- Now you can connect using that configuration file: sudo openvpn (where is the config file name of the server that you downloaded from your VPN provider).
- 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).
- The OpenVPN connection should now establish, and you will see confirmation with the words: Initialization Sequence Completed.
Setup OpenVPN on Fedora
- Open up a terminal window
- Download the components: $ sudo dnf install openvpn
- At this stage, you may be asked to enter your password to confirm your identity. Enter Y and press enter to confirm.
- To configure DNS enter the following: $ sudo cp /usr/share/doc/openvpn/contrib/pull-resolv-conf/client. /etc/openvpn/ $ sudo chmod +x /etc/openvpn/client. $ sudo sed -i.e. ‘s|\bresolvconf\b|ignore-&|’ /etc/openvpn/client.
- 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. - 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).
- The OpenVPN connection should now establish, and you will receive confirmation with the words: Initialization Sequence Completed.
Setup OpenVPN on Debian
- Open up a terminal window
- Run as superuser: su
- Download the components: apt-get update && apt-get upgrade && apt-get install curl openvpn
- At this stage, you may be asked to enter your password to confirm your identity. Enter Y and press enter to confirm.
- 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. - 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).
- 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.11/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 Free trial No Simultaneous connections Unlimited
From $5.50/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/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/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/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.