This guide helps Claude Code/Codex set up OpenClaw on a Hetzner server automatically.
Official docs: https://docs.openclaw.ai/start/getting-started
-
Hetzner API Token
- Go to https://console.hetzner.cloud
- Create a project (or use existing)
- Security > API Tokens > Generate API Token (Read & Write)
- Copy it
-
LLM API Key (pick one)
- Gemini (free): https://aistudio.google.com/apikey
- Anthropic (best): https://console.anthropic.com/settings/keys
-
SSH Key (if you don't have one)
ssh-keygen -t ed25519 -C "openclaw" cat ~/.ssh/id_ed25519.pub
# macOS
brew install hcloud
# Linux
curl -sSLO https://github.com/hetznercloud/cli/releases/latest/download/hcloud-linux-amd64.tar.gz
sudo tar -C /usr/local/bin --no-same-owner -xzf hcloud-linux-amd64.tar.gz
rm hcloud-linux-amd64.tar.gz# Create context (paste your API token when prompted)
hcloud context create openclaw# Check if key already exists
hcloud ssh-key list
# If not, create it:
hcloud ssh-key create --name openclaw-key --public-key-from-file ~/.ssh/id_ed25519.pub# Check if server already exists
hcloud server list
# If not, create it:
hcloud server create \
--name openclaw \
--type cpx22 \
--image ubuntu-24.04 \
--location nbg1 \
--ssh-key openclaw-keySave the IP address from the output.
# Wait 30s for boot, then:
ssh root@<SERVER_IP>apt update && apt upgrade -y
curl -fsSL https://openclaw.ai/install.sh | bash
source ~/.bashrc
openclaw --versionWith Gemini:
openclaw onboard \
--non-interactive \
--accept-risk \
--install-daemon \
--auth-choice gemini-api-key \
--gemini-api-key YOUR_KEY_HEREWith Anthropic:
openclaw onboard \
--non-interactive \
--accept-risk \
--install-daemon \
--auth-choice anthropic-api-key \
--anthropic-api-key YOUR_KEY_HEREopenclaw gateway status
openclaw doctoropenclaw channels add --channel whatsapp
openclaw channels login --channel whatsapp- QR code appears in terminal
- WhatsApp > Settings > Linked Devices > Link a Device
- Scan QR code
- Done
# Send yourself a WhatsApp message, or:
openclaw agent --message "Hello, what can you do?""SSH key already exists"
hcloud ssh-key list # Find existing key name
# Use that name in server create, or delete and recreate"Server name already exists"
hcloud server list
hcloud server delete openclaw # If you want to start fresh"Connection refused" on SSH
- Wait 60 seconds for server to fully boot
- Check:
hcloud server describe openclaw
"openclaw: command not found"
source ~/.bashrc
# Or add to PATH manually:
export PATH="$HOME/.openclaw/bin:$PATH"Gateway not starting
journalctl -u openclaw -f # Check logs
openclaw doctor # Run diagnostics# Delete server (stops billing)
hcloud server delete openclaw
# Optional: remove SSH key from Hetzner
hcloud ssh-key delete openclaw-key
# Optional: remove hcloud context
hcloud context delete openclawopenclaw doctor # Health check
openclaw gateway status # Gateway status
openclaw update # Update to latest
openclaw channels list # List connected channels
journalctl -u openclaw -f # View logs
systemctl restart openclaw # Restart daemonAsk user for:
- Hetzner API token
- LLM API key (Gemini or Anthropic)
Automation flow:
# 1. Setup hcloud (user pastes token when prompted)
hcloud context create openclaw
# 2. Upload SSH key (check first)
hcloud ssh-key list || hcloud ssh-key create --name openclaw-key --public-key-from-file ~/.ssh/id_ed25519.pub
# 3. Create server (check first)
hcloud server list | grep openclaw || hcloud server create --name openclaw --type cpx22 --image ubuntu-24.04 --location nbg1 --ssh-key openclaw-key
# 4. Get IP
SERVER_IP=$(hcloud server ip openclaw)
# 5. Wait and SSH
sleep 30
ssh root@$SERVER_IP
# 6. On server: install + onboard
apt update && apt upgrade -y
curl -fsSL https://openclaw.ai/install.sh | bash
source ~/.bashrc
openclaw onboard --non-interactive --accept-risk --install-daemon --auth-choice gemini-api-key --gemini-api-key <KEY>
# 7. Verify
openclaw gateway status
openclaw doctor
# 8. WhatsApp (user scans QR)
openclaw channels add --channel whatsapp
openclaw channels login --channel whatsappOnly manual step: WhatsApp QR scan