Skip to main content

How to set up manual OpenVPN connection using Linux Terminal


In this tutorial, you will learn how to set up an OpenVPN connection on your Linux device.

To set up OpenVPN on Linux, you will need a device running Linux OS and an active Surfshark subscription. The available plans are listed on Surfshark’s pricing page.

NOTE: This tutorial uses the Ubuntu distribution. Please note that some configurations may vary depending on the Linux distribution you are using. 

 

Get your credentials

NOTE: These are not your regular credentials, such as your email address and password.

  1. Enter the Surfshark login page and log in. Then, click on VPN > Manual Setup. This is the page where all the details required for manual connection are stored.

  2. Click Desktop or Mobile > OpenVPN. Proceed to the credentials tab. Click on the credentials tab at the top:

    Surfshark OpenVPN credentials page with username, password, and Generate new credentials

    NOTE: Keep this page open for now. You will need these credentials a bit later.

Download and install the OpenVPN package

  1. Open the terminal window. You can do that by pressing the Ctrl+Alt+T keys or navigating to it in your apps menu:
    Ubuntu apps menu with the Terminal icon highlighted

  2. Enter the following command to install all the necessary packages:
    sudo apt-get install openvpn unzip
    You may need to enter your computer password to confirm this process. In such a case, enter the password and press enter:
    Terminal prompting for a password after sudo apt-get install openvpn unzip

Download configuration files

  1. Navigate to the OpenVPN directory. You can do that by entering this command:
    cd /etc/openvpn
    Terminal showing the cd /etc/openvpn command

  2. Download the Surfshark OpenVPN configuration by entering the following command:
    sudo wget https://surfshark.com/api/v1/server/configurations
    Terminal running sudo wget to download Surfshark OpenVPN configurations

  3. Extract the configurations.zip by entering this command:
    sudo unzip configurations
    Terminal running sudo unzip configurations and listing extracted ovpn files

  4. Enter the following command to see the list of all the available servers:
    ls
    Terminal running ls to list available OpenVPN server files

 

Connect to the VPN

  1. Choose one server from the list that you want to connect to and copy the hostname (URL) representing this server's hostname:
    Terminal context menu with Copy selected on a server filename

  2. Connect to your chosen server by entering this command:
    sudo openvpn
    For example, if you'd like to connect to the us-slc server, this would be the command:
    sudo openvpn us-slc.prod.surfshark.com_udp.ovpn
    Terminal running sudo openvpn with a us-slc UDP configuration file

  3. Enter Surfshark service credentials (refer to the Get your credentials section in this article). Press enter:
    Terminal prompting for Auth Username and Auth Password

  4. If you can see the initialization sequence completed line in your terminal, you have successfully connected:
    Terminal showing Initialization Sequence Completed after connecting

  5. To disconnect from the OpenVPN connection, open the terminal and press Ctrl + C:
    Terminal showing the connection interrupted and returning to the prompt

 

Ensure the connection is successful

We always recommend checking if Surfshark VPN is working after setting it up for the first time. You can easily do this by performing a Surfshark IP leak test and a DNS leak test . Both are available on our website for your convenience.



You may also be interested in:

Was this article helpful?
Thank you for your feedback!