Introduction
This guide will walk you through the process of setting up a manual WireGuard® connection to Surfshark's servers on your Raspberry Pi. This method allows you to leverage the speed and security of the WireGuard® protocol for a secure and private internet connection while being connected to a Surfshark server.
Before you start
Before you begin the setup process, you will need the following:
- A Raspberry Pi with an operating system installed (e.g., Raspberry Pi OS).
- An active Surfshark subscription.
- Access to the terminal or command line on your Raspberry Pi.
Here's what to do
Step 1: Install WireGuard®
First, you need to install the WireGuard® package on your Raspberry Pi.
- Open the terminal on your Raspberry Pi.
Update your package list to ensure you get the latest version:
sudo apt updateInstall the WireGuard tools:
sudo apt install wireguard -y
Step 2: Get Surfshark Configuration and Keys
Next, you will generate your keys and download the server configuration file directly from your Surfshark account.
- Log in to your Surfshark account on the Surfshark website.
- Navigate to VPN > Manual setup > Router > WireGuard®.
- Click on "I don't have a key pair."
- Give your key pair a name and click "Generate a new key pair". The Surfshark website will display your Public and Private keys.
- Select a server location you wish to connect to and click "Download". This button will download a configuration file that includes your private key and the server's public key.
Step 3: Configure WireGuard® on Raspberry Pi
Now you will move the downloaded configuration file to the correct directory on your Raspberry Pi.
- Transfer the downloaded configuration file (e.g., surfshark.conf) to your Raspberry Pi. You can use a USB drive or a network transfer method like scp.
- Open the terminal on your Raspberry Pi.
Move the configuration file to the WireGuard® directory (for example, we select the Sweden Stockholm location, so the downloaded file name is se-sto.conf):
sudo mv /path/to/your/se-sto.conf /etc/wireguard/surfshark.confNOTE: Replace /path/to/your/surfshark.conf with the actual path to the file you transferred.
Step 4: Connect and Disconnect
You can now start the WireGuard® connection.
To bring the connection up, use the wg-quick command:
sudo wg-quick up surfsharkTo verify the connection is active and check the status, run:
sudo wgTo disconnect from the server, bring the interface down:
sudo wg-quick down surfshark
Additional tips
To make your Raspberry Pi automatically connect to the VPN when it starts, you can enable the wg-quick service:
sudo systemctl enable wg-quick@surfsharkNOTE: After wg-quick@, you must write the configuration file stored in etc/wireguard/ without the .conf at the end. In this tutorial, it is named surfshark.conf
After connecting, you use this command in a terminal to confirm that your public IP address has changed to the VPN server's location:
curl ipecho.net/plain