Skip to content

Configs and full guide for running homelab on Raspberry Pi 5

Notifications You must be signed in to change notification settings

vasujain275/homelab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Raspberry Pi Setup Guide

This guide outlines the steps for setting up a Raspberry Pi with Docker, SSH, Tailscale, Syncthing, and other essential tools for a homelab setup.


Table of Contents

  1. OS Installation
  2. SSH Setup
  3. First System Update
  4. Docker Installation
  5. Mounting External Drive Persistently
  6. Static IP Configuration
  7. ZSH4HUMANS Setup
  8. Setting Up GitHub SSH Keys
  9. Tailscale Setup
  10. Cloudflare Tunnels Setup
  11. Syncthing Setup

1. OS Installation

  1. Burn OS to SD Card:
    • Use Raspberry Pi Imager to burn Raspberry Pi OS Lite 64-bit to your SD card.
    • Default username: pi.

2. Setup SSH Keys

  1. Copy SSH Key:

    • On your PC, go to the ~/.ssh folder and copy the public SSH key you wish to use.
  2. 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.

3. First System Update

To ensure your Raspberry Pi is up-to-date, run the following commands:

sudo apt update && sudo apt upgrade

4. Docker Installation

Uninstall Conflicting Versions

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

Install Docker

  1. 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
  2. Install Docker:

    sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
  3. Add User to Docker Group:

    sudo groupadd docker
    sudo usermod -aG docker $USER

Refer to the official Docker installation guide for Debian here.


5. Ensure to follow steps in setups/services/hdd-mount to mount external hdd on boot


6. Static IP Configuration

1. Find Network Interface Name

nmcli con show

Copy the name of the wifi connection.

2. Backup Original Settings

sudo nmcli con show "Name that you copied" | tee original_network_settings.txt

3. Set Static IP

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

7. ZSH4HUMANS Setup

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

8. Setting Up New GitHub SSH Keys

1. Generate New SSH Key

ssh-keygen -t ed25519 -C "[email protected]"

Use homelab_gh as the key name.

2. Add SSH Key to the SSH Agent

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/homelab_gh

3. Add SSH Key to GitHub

Follow the GitHub guide.


9. Tailscale Setup

1. Install Tailscale

curl -fsSL https://tailscale.com/install.sh | sh

2. Login

sudo tailscale login

3. Enable Subnets

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

4. Subnet Optimisation for Ethernet

NETDEV=$(ip route show 0/0 | cut -f5 -d' ')
sudo ethtool -K $NETDEV rx-udp-gro-forwarding on rx-gro-list off

5. Enable on Boot

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

10. Cloudflare Tunnels Setup

  1. Navigate to Cloudflare Dashboard > Zero Trust > Networks > Tunnels.
  2. Configure the tunnel as per the instructions.

11. Syncthing Setup

1. Install Syncthing

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

2. Enable and Start the Service

sudo systemctl enable [email protected]
sudo systemctl start [email protected]

About

Configs and full guide for running homelab on Raspberry Pi 5

Resources

Stars

Watchers

Forks

Languages