OpenVPN on Linux using the terminal

This guide describes how to connect to our service using OpenVPN on Linux, via terminal.
First, make sure openvpn is installed by running in terminal: openvpn --version
You can either set a one-time connection, which will be active in the terminal session until you disconnect (CTRL+C) or close the terminal, or you can set an active connection started by the openvpn service on-boot.

Important Notes:

  • Basic Linux usage knowledge on how to run a terminal session and manage files is required. We are not covering that.
  • we recommend to use static DNS servers set in /etc/resolv.conf (not a statically linked file) such as:
    nameserver 9.9.9.9
    While connected to the VPN, you will use our private DNS resolvers regardless of what public DNS server is set in /etc/resolv.conf
    Disabling the systemd-resolved is recommended (not using localhost as DNS resolver) because it is known to cause trouble with the DNS lookups while using the VPN connection. More info on how to disable it: here.

Method 1
This method is for setting up an OpenVPN connection manually (one-time).

  1. Download any of the server profiles from our repository. You can either download individual .ovpn profiles or a zip containing all of them.
  2. run in terminal either as root if your session is already elevated or by using sudo: (sudo) openvpn [path to the .ovpn file]such as sudo openvpn ./finland-aes256-udp.ovpn
    OpenVPN will ask you to insert the VPN username and password to authenticate.
    Alternatively, you can insert your VPN user and password to a file so that it will read the credentials automatically.
    Saving the VPN user/pass to a file:
  • create a text file such as auth.txt and add your VPN username and password, one per line. Create it either one of the editors like vim, nano or by using echo:
    echo "myvpnusername" > auth.txt; echo "myvpnpassword" >> auth.txt
  • edit the .ovpn file and find the line auth-user-pass, change it to auth-user-pass auth.txt
    If you have multiple server profiles, you can use the sed utility to mass-change the files, such as:
    sed -i 's,auth-user-pass,auth-user-pass auth.txt,g' *.ovpn

Method 2
This method is for setting up an automatic/permanent OpenVPN connection managed by systemd.

  1. Download the .ovpn server profile you want to use from our repository, move it to /etc/openvpn/vpnac.conf
    You can save it using any different, more descriptive name such as vpnacfrance.conf
  2. Save the VPN username and password to the text file in /etc/openvpn/auth.txt (see step 2 above) and make the necessary change to the server profile auth-user-pass auth.txt
  3. Edit the file /etc/default/openvpn and specify which server profile to use by changing the AUTOSTART=ALL parameter to AUTOSTART=vpnac or what server profile you want to use.
    Enable and start openvpn:
    (sudo) systemctl enable openvpn
    (sudo) systemctl start openvpn
    Check if it is connected, else it should show relevant errors in /var/log/syslog
    To disconnect: (sudo) systemctl stop openvpn
    To disable it: (sudo) systemctl disable openvpn

Other tutorials: