PiVPN is a popular VPN solution for Raspberry Pi. It sets up a VPN server that can be used from any device that supports OpenVPN. In this tutorial, we will be installing and setting up PiVPN on a Debian latest server.
To follow this tutorial, you will need the following:
The first step is to download and install PiVPN. To do this, we will need to execute a shell script provided by PiVPN. Here are the commands you need to run:
sudo apt update && sudo apt upgrade
sudo apt install openvpn -y
sudo apt install wget git -y
curl -L https://install.pivpn.io | bash
Now that PiVPN is installed, we need to configure it.
pivpn add nopass
Enter a name for your certificate authority. It can be anything you want.
We will now generate the server certificate. Run the following command to do this:
pivpn add -n
You'll be prompted for a name for your server certificate. Enter a name you'll remember, like "myvpn", for example.
Next, you'll set the server to use a static IP address. Enter the IP address of your server.
We will now generate the client certificate. Run the following command to do this:
pivpn add
You'll be prompted for a name for your client certificate. Enter a name you'll remember, like "mycomputer", for example.
Repeat the above steps for each client device you want to connect to the VPN.
Now that the certificates are generated, we can start the VPN server.
pivpn -a
You will be asked to select the user you want to run the server as. Select the default user "pi".
You will now be prompted for a password to encrypt your client profiles. Enter a password you'll remember.
Now that the server is up and running, we can connect a client to the VPN.
On your client device, download and install the OpenVPN client.
Copy the client certificate file from your server to your client device. You can find this file in the /home/pi/ovpns/ directory on your server.
Import the certificate into the OpenVPN client.
Connect to the VPN by clicking the "Connect" button in the OpenVPN client.
Enter the password you set in Step 3 when prompted.
And that's it! You should now be able to connect to your VPN from your client device.
If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!
Alternatively, for the best virtual desktop, try Shells!