Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Connecting via VPN (Linux)

Follow this guide to privately access your server from your Linux device using a VPN.

Prerequisites

Contents

WireGuard

  1. Obtain a WireGuard config file for your device.

    • StartTunnel: Follow instructions here
    • Router: Follow your router’s instructions.
  2. Install wireguard and wireguard-tools.

    • Debian / Ubuntu

      sudo apt update && sudo apt install wireguard
      
    • Fedora / RHEL

      sudo dnf update && sudo dnf install wireguard-tools
      
    • Arch / Manjaro

      sudo pacman -Syu && sudo pacman -S wireguard-tools && sudo pacman -S wireguard
      
  3. Move into the directory where you downloaded your Root CA (usually ~/Downloads), for example:

    cd ~/Downloads
    
  4. Copy the contents of your WireGuard configuration file into /etc/wireguard/wg0.conf (or enter them from your notes)

    sudo mv myconf.conf /etc/wireguard/wg0.conf
    

    Be certain to replace myconf.conf with the name of the file you downloaded.

  5. Set the permissions on the configuration file correctly:

    sudo chmod 600 /etc/wireguard/wg0.conf
    
  6. Bring the interface up using wp-quick, which will create the interface and necessary routing rules for you the first time you use it.

    sudo wg-quick up wg0
    
  7. Verifiy that a this worked by examining the output of:

    sudo wg
    
  8. Enable WireGuard on Boot (optional) - this would connect you each time you boot

    sudo systemctl enable wg-quick@wg0
    

Tip

Each time you want to close the VPN connection: sudo wg-quick down wg0

OpenVPN

  1. Install openvpn.

    • Debian / Ubuntu

      sudo apt update && sudo apt install openvpn
      
    • Fedora / RHEL

      sudo dnf update && sudo dnf install openvpn
      
    • Arch / Manjaro

      sudo pacman -Syu && sudo pacman -S openvpn
      
  2. Move into the directory where you downloaded your Root CA (usually ~/Downloads), for example:

    cd ~/Downloads
    
  3. Copy the contents of your OpenVPN configuration file into /etc/openvpn/client.conf (or enter them from your notes)

    sudo mv myconf.ovpn /etc/openvpn/client.conf
    

    Be certain to replace myconf.ovpn with the name of the file you downloaded.

  4. Set the permissions on the configuration file correctly:

    sudo chmod 600 /etc/openvpn/client.conf
    
  5. Start OpenVPN and load the config file, entering your username and password when requested.

    sudo systemctl start openvpn@client
    
  6. Verifiy that a this worked by examining the output of:

    sudo systemctl status openvpn@client
    
  7. Enable OpenVPN on Boot (optional) - this would connect you each time you boot

    sudo systemctl enable openvpn@client
    

Tip

Each time you want to close the VPN connection: sudo systemctl stop openvpn@client