This guide outlines the steps for setting up a Raspberry Pi with Docker, SSH, Tailscale, Syncthing, and other essential tools for a homelab setup.
- OS Installation
- SSH Setup
- First System Update
- Docker Installation
- Mounting External Drive Persistently
- Static IP Configuration
- ZSH4HUMANS Setup
- Setting Up GitHub SSH Keys
- Tailscale Setup
- Cloudflare Tunnels Setup
- Syncthing Setup
- Burn OS to SD Card:
- Use Raspberry Pi Imager to burn Raspberry Pi OS Lite 64-bit to your SD card.
- Default username:
pi
.
-
Copy SSH Key:
- On your PC, go to the
~/.ssh
folder and copy the public SSH key you wish to use.
- On your PC, go to the
-
SSH to Raspberry Pi:
- SSH into the Raspberry Pi using the password:
ssh pi@<raspberry-pi-ip>
- Run the following commands to set up SSH key authentication:
mkdir .ssh cd .ssh touch authorized_keys nano authorized_keys
- Paste your public key into
authorized_keys
and save.
- SSH into the Raspberry Pi using the password:
To ensure your Raspberry Pi is up-to-date, run the following commands:
sudo apt update && sudo apt upgrade
To remove any existing Docker installations:
for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done
-
Set up Docker's Apt Repository:
sudo apt-get update sudo apt-get install ca-certificates curl sudo install -m 0755 -d /etc/apt/keyrings sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc sudo chmod a+r /etc/apt/keyrings/docker.asc echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \ $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ sudo tee /etc/apt/sources.list.d/docker.list > /dev/null sudo apt-get update
-
Install Docker:
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
-
Add User to Docker Group:
sudo groupadd docker sudo usermod -aG docker $USER
Refer to the official Docker installation guide for Debian here.
nmcli con show
Copy the name
of the wifi connection.
sudo nmcli con show "Name that you copied" | tee original_network_settings.txt
sudo nmcli con mod "Name that you copied" ipv4.method manual ipv4.addr 192.168.1.50/24
sudo nmcli con mod "Name that you copied" ipv4.addr 192.168.1.50/24 ipv4.gateway 192.168.1.1 ipv4.dns 1.1.1.1 ipv4.method manual
To install ZSH4HUMANS for an enhanced Zsh experience:
if command -v curl >/dev/null 2>&1; then
sh -c "$(curl -fsSL https://raw.githubusercontent.com/romkatv/zsh4humans/v5/install)"
else
sh -c "$(wget -O- https://raw.githubusercontent.com/romkatv/zsh4humans/v5/install)"
fi
ssh-keygen -t ed25519 -C "[email protected]"
Use homelab_gh
as the key name.
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/homelab_gh
Follow the GitHub guide.
curl -fsSL https://tailscale.com/install.sh | sh
sudo tailscale login
Enable local network access and configure the Raspberry Pi as an exit node:
echo 'net.ipv4.ip_forward = 1' | sudo tee -a /etc/sysctl.d/99-tailscale.conf
echo 'net.ipv6.conf.all.forwarding = 1' | sudo tee -a /etc/sysctl.d/99-tailscale.conf
sudo sysctl -p /etc/sysctl.d/99-tailscale.conf
Enable subnet routes from the admin console and run the following command:
sudo tailscale up --advertise-routes=192.168.0.0/24,192.168.1.0/24 --advertise-exit-node
NETDEV=$(ip route show 0/0 | cut -f5 -d' ')
sudo ethtool -K $NETDEV rx-udp-gro-forwarding on rx-gro-list off
printf '#!/bin/sh\n\nethtool -K %s rx-udp-gro-forwarding on rx-gro-list off \n' "$(ip route show 0/0 | cut -f5 -d" ")" | sudo tee /etc/networkd-dispatcher/routable.d/50-tailscale
sudo chmod 755 /etc/networkd-dispatcher/routable.d/50-tailscale
- Navigate to Cloudflare Dashboard > Zero Trust > Networks > Tunnels.
- Configure the tunnel as per the instructions.
sudo mkdir -p /etc/apt/keyrings
sudo curl -L -o /etc/apt/keyrings/syncthing-archive-keyring.gpg https://syncthing.net/release-key.gpg
echo "deb [signed-by=/etc/apt/keyrings/syncthing-archive-keyring.gpg] https://apt.syncthing.net/ syncthing stable" | sudo tee /etc/apt/sources.list.d/syncthing.list
sudo apt-get update
sudo apt-get install syncthing
sudo systemctl enable [email protected]
sudo systemctl start [email protected]