A comprehensive, security-first guide to install and run OpenClaw on Raspberry Pi OS (SSD or SD), using SSH keys, UFW, Fail2ban, and safe-by-default gateway settings.
Quick Start »
Security Baseline
·
Raspberry Pi OS Install
·
Pi Hardening
·
OpenClaw Install
·
Onboarding Settings
·
Verification
- Quick Start
- About
- Security Baseline
- Prerequisites
- Raspberry Pi OS Install
- First Boot Checklist
- Pi Hardening
- Install Node.js 22+
- Install OpenClaw
- OpenClaw Onboarding Settings
- Run as a Service
- Security Audit
- Common Issues
- Links
- Disclaimer
If you already have Raspberry Pi OS running and SSH access working:
# update base OS
sudo apt update
sudo apt full-upgrade -y
sudo apt install -y git curl ca-certificates ufw fail2ban unzip openssl
# enable firewall (SSH only)
sudo ufw allow OpenSSH
sudo ufw --force enable
sudo ufw status verbose
# enable fail2ban
sudo systemctl enable --now fail2ban
# install Node.js 22+
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt install -y nodejs
# install OpenClaw
sudo npm install -g openclaw@latest
openclaw --version
# run onboarding
openclaw onboardDuring onboarding, bind the gateway to localhost only:
- ✅
127.0.0.1 - ❌ not
0.0.0.0
Then install the Gateway service and run a security audit:
openclaw security audit --deepThis guide installs OpenClaw on a Raspberry Pi using a security-first baseline:
- SSH keys-only access
- Firewall enabled (deny inbound by default)
- Fail2ban enabled (SSH brute-force protection)
- OpenClaw Gateway bound to localhost (no LAN exposure)
- Gateway auth token set to a strong random value
- Credential directory permissions locked down
The goal is to build a stable “appliance-like” Pi host: boring, predictable, and safe.
- Do NOT expose OpenClaw Control UI directly to the internet.
- Do NOT port-forward your router to the Raspberry Pi.
- Bind OpenClaw gateway to
127.0.0.1(localhost only). - Keep UFW enabled with default deny incoming.
If the gateway binds to 0.0.0.0, anything on your network can attempt to connect.
If misconfigured further, you could accidentally expose an admin surface externally.
Binding to 127.0.0.1 makes it private by default.
- Raspberry Pi (Pi 4 recommended)
- SD card OR USB SSD
- Power supply
- Ethernet or Wi-Fi
- macOS / Linux / Windows machine
- SSH client
- Raspberry Pi Imager installed (GUI)
✅ Raspberry Pi OS Lite (64-bit)
It’s stable and minimal, and you can add only what you need later.
-
Open Raspberry Pi Imager
-
Select:
- OS: Raspberry Pi OS Lite (64-bit)
- Storage: your SD card or SSD
-
Open Advanced settings (gear icon) and set:
- Hostname: e.g.
clawpi - Enable SSH: ✅
- Authentication: ✅ use password (temporary is fine)
- Username: choose a dedicated user (example:
openclaw) - Wi-Fi: configure if needed
- Locale/timezone: optional
- Hostname: e.g.
-
Write image
-
Boot your Pi
Tip: If you can’t SSH after boot, it’s usually Wi-Fi settings, hostname mismatch, or the wrong username.
Once the Pi boots, SSH in:
ssh <user>@<hostname>.localIf .local does not resolve, use the IP from your router:
ssh <user>@192.168.x.xThen confirm basics:
whoami
hostname
uname -aOn your workstation (Mac/Linux), create a key if needed:
ssh-keygen -t ed25519 -C "pi-admin"Copy your public key to the Pi:
ssh-copy-id <user>@<pi-ip-or-hostname>Verify it works:
ssh <user>@<pi-ip-or-hostname>Edit:
sudo nano /etc/ssh/sshd_configSet:
PermitRootLogin no
PasswordAuthentication no
PubkeyAuthentication yes
Restart SSH:
sudo systemctl restart sshInstall + enable:
sudo apt install -y ufw
sudo ufw allow OpenSSH
sudo ufw --force enable
sudo ufw status verboseExpected:
- Default deny incoming
- SSH allowed
Install + enable:
sudo apt install -y fail2ban
sudo systemctl enable --now fail2ban
sudo systemctl status fail2ban --no-pagerRaspberry Pi OS may use zram by default.
Check swap:
swapon --show
free -hIf swap exists (zram or swapfile), you're good.
Install Node.js 22 from NodeSource:
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt install -y nodejs
node -v
npm -vYou should see Node v22.x.
Install globally:
sudo npm install -g openclaw@latest
openclaw --version
openclaw --helpRun onboarding:
openclaw onboardIf onboard is not available:
openclaw configure- Gateway bind: ✅
127.0.0.1 - Gateway port: ✅ default is fine
- Gateway auth: ✅ Token
- Gateway token: ✅ long random token
- Tailscale exposure: ✅ Off
- Hooks: ✅ Skip for now
- Skills: ✅ Skip for now (start minimal)
Generate a strong token:
openssl rand -hex 32Set it:
openclaw config set gateway.auth.token "<PASTE_TOKEN_HERE>"Restart gateway service after changes:
systemctl --user restart openclaw-gatewayOnboarding will typically install the Gateway user service:
openclaw-gateway.service(systemd user service)
Check status:
systemctl --user status openclaw-gateway --no-pagerView logs:
journalctl --user -u openclaw-gateway -n 200 --no-pagerRestart service:
systemctl --user restart openclaw-gatewaysystemctl --user status openclaw-gateway --no-pagerss -lntp | grep 18789 || trueExpected output includes:
127.0.0.1:18789[::1]:18789
If you see 0.0.0.0:18789, your gateway is exposed to LAN and must be fixed.
Run the deep audit:
openclaw security audit --deepExpected:
- 0 critical
Note:
gateway.trusted_proxies_missingis safe to ignore if you keep the UI local-only.- If you expose a Control UI through a reverse proxy later, configure
gateway.trustedProxies.
You are using the wrong username, or your public key was not copied to the Pi.
Fix:
ssh-copy-id <user>@<pi-ip-or-hostname>This is normal.
Always allow SSH before enabling UFW:
sudo ufw allow OpenSSH
sudo ufw --force enableThis usually means npm is trying to write to a system directory. For a minimal secure setup, skip skills until your base install is stable.
For detailed, step-by-step setup of specific features, refer to these reference guides:
- Detailed AI Model & Web Setup — Comprehensive guide for Anthropic API and Brave Search integration.
- Secure Telegram Integration — Instructions for bot creation, privacy settings, and whitelisting.
- Web Search & Skill Management — How to extend your bot's capabilities and perform security audits.
-
OpenClaw: https://github.com/openclaw/openclaw
-
OpenClaw Docs: https://docs.openclaw.ai
This guide is provided as-is. You are responsible for reviewing and understanding commands before running them.
- Disk flashing wipes data.
- Security settings must be validated in your environment.
- Do not expose admin/control surfaces to the internet without additional protections.