How to Install PiVPN on Debian Latest

Introduction

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.

Prerequisites

To follow this tutorial, you will need the following:

Step 1 - Install PiVPN

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:

  1. First, update the packages on your server:
sudo apt update && sudo apt upgrade
  1. Next, install OpenVPN and some other dependencies that PiVPN needs:
sudo apt install openvpn -y
sudo apt install wget git -y
  1. Now, download and install PiVPN by running the following command:
curl -L https://install.pivpn.io | bash

Step 2 - Configure PiVPN

Now that PiVPN is installed, we need to configure it.

  1. First, we need to generate a certificate authority (CA) certificate. This certificate is used to generate server and client certificates. To generate the CA certificate, run the following command:
pivpn add nopass
  1. Enter a name for your certificate authority. It can be anything you want.

  2. We will now generate the server certificate. Run the following command to do this:

pivpn add -n
  1. You'll be prompted for a name for your server certificate. Enter a name you'll remember, like "myvpn", for example.

  2. Next, you'll set the server to use a static IP address. Enter the IP address of your server.

  3. We will now generate the client certificate. Run the following command to do this:

pivpn add
  1. You'll be prompted for a name for your client certificate. Enter a name you'll remember, like "mycomputer", for example.

  2. Repeat the above steps for each client device you want to connect to the VPN.

Step 3 - Start the VPN Server

Now that the certificates are generated, we can start the VPN server.

  1. Run the following command to start the server:
pivpn -a
  1. You will be asked to select the user you want to run the server as. Select the default user "pi".

  2. You will now be prompted for a password to encrypt your client profiles. Enter a password you'll remember.

Step 4 - Connect to the VPN

Now that the server is up and running, we can connect a client to the VPN.

  1. On your client device, download and install the OpenVPN client.

  2. 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.

  3. Import the certificate into the OpenVPN client.

  4. Connect to the VPN by clicking the "Connect" button in the OpenVPN client.

  5. 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!