How to Install and Configure Tailscale VPN on Raspberry Pi: A Step-by-Step Guide

This guide provides detailed instructions for setting up Tailscale VPN on your Raspberry Pi, enabling secure remote access and network connectivity.

Table of Contents

Prerequisites

  • A Raspberry Pi (any model) running Raspberry Pi OS (formerly Raspbian)
  • Internet connection
  • SSH access or direct access to the Raspberry Pi terminal
  • Sudo privileges on your Raspberry Pi
  • A Tailscale account (free or paid)

System Preparation

First, ensure your system is up to date:

sudo apt-get update && sudo apt-get -y upgrade

Install required dependencies:

sudo apt install lsb-release curl

Installing Tailscale

  1. Add the Tailscale GPG key to your system:
curl -L https://pkgs.tailscale.com/stable/raspbian/$(lsb_release -cs).noarmor.gpg | \
  sudo tee /usr/share/keyrings/tailscale-archive-keyring.gpg >/dev/null
  1. Add the Tailscale repository to your package sources:
echo "deb [signed-by=/usr/share/keyrings/tailscale-archive-keyring.gpg] \
  https://pkgs.tailscale.com/stable/raspbian $(lsb_release -cs) main" | \
  sudo tee /etc/apt/sources.list.d/tailscale.list
  1. Update package list and install Tailscale:
sudo apt-get update
sudo apt -y install tailscale
  1. Reboot your Raspberry Pi to ensure all changes take effect:
sudo reboot

Configuration and Authentication

  1. After reboot, start Tailscale:
sudo tailscale up
  1. You’ll receive a URL similar to:
To authenticate, visit:

https://login.tailscale.com/a/xxxxxxxxxxxx
  1. Open this URL in your web browser and log in to your Tailscale account
  2. Approve the device connection in the Tailscale admin console

Security Considerations

  • By default, Tailscale operates in a secure mode where your Raspberry Pi can only communicate with other devices on your Tailscale network
  • Consider enabling MFA on your Tailscale account for additional security
  • Regularly update both Tailscale and your Raspberry Pi OS to receive security patches
  • Review and adjust node permissions in the Tailscale admin console as needed

Verifying Installation

Check Tailscale status:

sudo tailscale status

This will show all connected devices and their IP addresses within your Tailscale network.

Troubleshooting

If you encounter issues:

  1. Check system logs:
sudo journalctl -u tailscaled
  1. Verify Tailscale service status:
sudo systemctl status tailscaled
  1. Common solutions:
    • Ensure your Raspberry Pi has a stable internet connection
    • Verify that the tailscaled service is running
    • Check firewall settings if you have modified them
    • Confirm your Tailscale account is active and the device is authorized

Additional Resources


Remember to replace xxxxxxxxxxxx in the authentication URL with the actual code provided during your setup process. This guide is compatible with all current Raspberry Pi models and recent versions of Raspberry Pi OS.

For automatic startup on boot:

sudo systemctl enable --now tailscaled

If you need the script.

#!/bin/sh

# Installing Tailscale to the Raspberry Pi
# https://pimylifeup.com/raspberry-pi-tailscale/

# update the package list and any out-of-date packages
sudo apt-get update && sudo apt-get -y upgrade

# install needed packages
sudo apt install lsb-release curl

# get the GPG key for the Tailscale repository
curl -L https://pkgs.tailscale.com/stable/raspbian/$(lsb_release -cs).noarmor.gpg | sudo tee /usr/share/keyrings/tailscale-archive-keyring.gpg >/dev/null

# add the Tailscale repository
echo "deb [signed-by=/usr/share/keyrings/tailscale-archive-keyring.gpg] https://pkgs.tailscale.com/stable/raspbian $(lsb_release -cs) main" | sudo tee  /etc/apt/sources.list.d/tailscale.list

# update the package list
sudo apt-get update

# install Tailscale
sudo apt -y install tailscale

# restart device
sudo reboot

# start up the Tailscale network
sudo tailscale up

# copy "https://login.tailscale.com/a/XXXXXXXXXXXX" URL to your favorite browser and login to Tailscale

# admin@rpi777:~ $ sudo tailscale up
#
# To authenticate, visit:
#
#         https://login.tailscale.com/a/c03e43d5bd19