Raspberry Pi: Complete Headless Setup Guide (No Monitor Needed)
Setting up a Raspberry Pi without a monitor, keyboard, or mouse is the cleanest way to deploy one. This guide goes from bare card to a fully accessible Pi on your network — including static IP, SSH key auth, and firewall basics.
Step 1: Flash with the Right Settings
Open Imager. For headless deployment, choose Raspberry Pi OS Lite (64-bit) — no desktop, less RAM usage, faster boot. Before writing, click the gear icon or press Ctrl+Shift+X to open Advanced Options. Configure:
- Hostname: Something meaningful —
pi-shop,pi-cam,pi-proxy - Enable SSH: Yes. Use password auth for now, switch to key-only after first login
- WiFi credentials: SSID + password if going wireless. Leave blank for Ethernet-only
- Locale and timezone: Set your region — the system clock will be correct from boot
Write the image. Safely eject. Do not manually add a ssh file to the card — Imager handles it through firstrun.sh on modern OS versions.
Step 2: Boot and Find the Pi
Insert card, plug in Ethernet if using it, apply power. First boot takes 60–90 seconds — the Pi expands the filesystem and applies your config. Once it's up, find its IP address:
- Hostname ping:
ping pi-shop.local— works if your router supports mDNS (most modern routers do) - Router DHCP table: Log into your router admin panel, check lease list for a new device
- Network scan:
nmap -sn 192.168.1.0/24— adjust subnet to match yours
Step 3: SSH In and Update
ssh [email protected]
Accept the host fingerprint. Enter your password. Once in, immediately update:
sudo apt update && sudo apt full-upgrade -y
sudo reboot
After reboot, SSH back in. Your Pi is now running current packages.
Step 4: Switch to SSH Key Authentication
On your local machine, generate a key pair if you don't have one:
ssh-keygen -t ed25519 -C "pi-shop"
Copy your public key to the Pi:
ssh-copy-id [email protected]
Test that key auth works before disabling passwords:
ssh -i ~/.ssh/id_ed25519 [email protected]
Once confirmed, disable password auth. Edit /etc/ssh/sshd_config:
PasswordAuthentication no
ChallengeResponseAuthentication no
PubkeyAuthentication yes
sudo systemctl restart ssh
Step 5: Set a Static IP
Best approach: DHCP reservation on your router. Get the Pi's MAC address:
ip link show eth0 # or wlan0 for WiFi
Enter that MAC in your router's static lease table with your chosen IP. The Pi always gets the same address without any config on the Pi itself — cleaner and easier to change later.
Alternative: Static config on the Pi. Edit /etc/dhcpcd.conf:
interface eth0
static ip_address=192.168.1.50/24
static routers=192.168.1.1
static domain_name_servers=1.1.1.1 8.8.8.8
Reboot to apply. Reconnect using the new IP.
Step 6: Firewall and Essentials
sudo apt install -y ufw vim tmux htop curl git
sudo ufw allow ssh
sudo ufw enable
sudo ufw status
UFW (Uncomplicated Firewall) blocks everything except SSH by default. Add more rules as needed — sudo ufw allow 80/tcp for a web server, sudo ufw allow 1883/tcp for MQTT, etc.
Troubleshooting
- Pi not found on network: Give it a full 2 minutes. Confirm WiFi credentials were correct in Imager. Try Ethernet as a fallback.
- SSH connection refused: SSH wasn't enabled in Imager settings. Reflash and check the Advanced Options box.
- Pi drops WiFi randomly: Power supply issue — underpowered units drop WiFi under load. Use the official PSU (5.1V/3A for Pi 4, 5.1V/5A for Pi 5).
- Permission denied (publickey): Your public key isn't in
~/.ssh/authorized_keyson the Pi, or the permissions are wrong. Runchmod 700 ~/.ssh && chmod 600 ~/.ssh/authorized_keyson the Pi. - Host key warning on reconnect: Happened after a reflash. Run
ssh-keygen -R pi-shop.localon your machine to clear the old fingerprint.