How to set up a VPN on Linux

As a Linux user, you probably care a lot about privacy and security. Hence, you should be interested in harnessing the power of a virtual private network (VPN). But how do you set up a VPN on Linux?

There are several ways to do it:

Solution #1. Install a Linux-compatible VPN app.

Solution #2. Set up a VPN manually using OpenVPN.

Bonus solution: Use Ubuntu Network Manager.

We’ll be using Surfshark for demonstration purposes.

Solution #1. Set up a VPN on Linux with the Surfshark app

Solution #2. Set up a VPN on Linux manually

Granted, not all devices support VPN apps. Therefore, you may need to carry out the setup manually by getting the VPN configuration files from your VPN provider and using them with OpenVPN. Here’s how:

  1. Open the terminal window by pressing Ctrl + Alt + T.

  1. Install the required OpenVPN materials by using the command “sudo apt-get install openvpn unzip”.

If you are requested to enter your password, please enter your computer’s admin password.

  1. Go to the OpenVPN directory by entering the command “cd /etc/openvpn”.

terminal screenshot 6

  1. Log into Surfshark.

Sign up for a Surfshark

  1. Get the Surfshark OpenVPN configuration files by entering the command “sudo wget”

Terminal screenshot

  1. Extract the `` with the command “sudo unzip configurations”.

Surfshark terminal screenshot

  1. Remove the .zip file which will no longer be needed.

terminal screenshot 9

  1. Open the list of available servers by entering “ls” in the command line.

Surfshark terminal screenshot

  1. To connect to a chosen Surfshark server, enter the command “sudo openvpn [file name]”.

For example, here’s how you connect to a Dallas server:

sudo openvpn

sudo openvpn /etc/openvpn/

terminal screenshot 11

  1. To find your Surfshark service credentials (they’re not the same as your account login information) for OpenVPN, log into your account on and go to the Manual setup page.

terminal screenshot 12

  1. If you see “Initialization Sequence Completed” in the terminal logs, you have successfully connected to Surfshark.

initilization sequence terminal

  1. If you want to disconnect from OpenVPN, open the terminal and press Ctrl+C.

terminal screenshot

If you have any questions about the process, you can always turn to our customer support service that works 24/7 via email or live chat. 

Bonus: set up a VPN using Ubuntu Network Manager

Are you an Ubuntu user? Then you can set up Surfshark by using your handy Network Manager app. Here’s how it’s done:

  1. If the Network Manager is not installed on your device, open the Terminal (Ctrl+Alt+T) and enter the command “sudo apt-get install network-manager-openvpn-gnome”.

Terminal screenshot
You will be asked to enter your computer’s password – do so. 

  1. Once you have the Network Manager, sign up for Surfshark.

Sign up for a Surfshark

  1. Log in to the Surfshark website and go to the Manual setup page..
  2. Download the UDP files for the server you wish to connect to and save them on your desktop for convenience. Don’t close the window yet – we’ll need it later.

countries list screenshot

  1. Click the white arrow or the Wi-Fi/Ethernet icon – it should be at the top-right corner of your desktop.

linux settings screen

  1. Click the “Settings” button.

  1. Open the “Network” tab. 

linux network settings cable unticked

  1. Click the “+” sign to add a new VPN network.

linux network settings

  1. In the new window, click “import from file”.

add vpn menu on Linux

  1. Navigate to the file you downloaded during step #4 and import it.

Linux VPN authentication page

  1. Once you’re asked for authentication, enter the Surfshark service credentials that you can find at the bottom of the page you opened during step #3.
  2. A new VPN profile is added. Turn it on by flipping the switch to “ON.”

Linux Network settings

  1. To see if the VPN is connected, open the system tray the way you did in step #5.

And that’s all there is to it! Again, if you have questions, our 24/7 support team is always ready to help. 

Secure your Linux experience with a VPN now

Linux is the system of choice for people who value privacy and security. However, the privacy and security benefits of Linux don’t extend to the internet, and that’s why you need additional help. Set up a Linux VPN on your distribution of choice and experience the freedom of the internet that you deserve.

Get a VPN for Linux!

Get Surfshark