Skip to main content

[How-To] Install and Setup PiVPN on Raspberry Pi

Purpose

A dedicated doc to show how to install and initially configure the PiVPN appliance on Raspberry Pi. 

Prerequisites

List of prerequisites:

  • Raspberry Pi System fully updated
  • Sudo access
  • Internet access

Instructions for installing PiVPN on Raspberry Pi

Step 1: Verify System is Up to Date

Update the system if it isn't already:

sudo apt update && sudo apt upgrade -y

Then, reboot.

sudo reboot

Step 2: Install the PiVPN Server

Run this command to kick off the install to PiVPN:

sudo curl -L https://install.pivpn.io | bash

Then, follow the interactive installer which will:

  • Static IP check → If not already static, set one.

  • Choose VPN type:

    • WireGuard (faster, lighter, recommended for most)

    • OpenVPN (more compatibility with older devices)

  • Port selection → Default is fine unless you need something custom.

  • DNS provider → Choose from the list or use custom.

  • Public IP / Dynamic DNS → Enter your external IP or DDNS hostname.

  • Unattended upgrades → Recommended to enable.

After installation, reboot again:

sudo reboot

Step 3: Add a VPN Client

Run this command to add a VPN client to the PiVPN Server for VPN connections:

sudo pivpn add

If you want to do a keypair for authentication instead of a password, add a user with the no password flag:

sudo pivpn add nopass

Once this is generated, run this to find the config file:

sudo pivpn -qr

Here are some other useful commands:

pivpn add         # Add a new client
pivpn add nopass  # Add a new client with no password
pivpn list        # List all clients
pivpn revoke      # Remove a client
pivpn -qr         # Show QR code for WireGuard config
pivpn debug       # Troubleshoot VPN Setup

At this point, you should have a functioning PiVPN Server!