← 返回
安全合规 中文

Host Hardening

Harden an OpenClaw Linux server with SSH key-only auth, UFW firewall, fail2ban brute-force protection, and credential permissions. Use when setting up a new...
加固OpenClaw Linux服务器:配置仅SSH密钥认证、UFW防火墙、fail2ban防暴力破解及凭证权限。适用于新...
ppiankov
安全合规 clawhub v1.0.5 3 版本 99918.8 Key: 无需
★ 0
Stars
📥 1,231
下载
💾 10
安装
3
版本
#latest

概述

Host Hardening

Secure a Linux server running OpenClaw.

Requirements

  • OS: Linux (Ubuntu/Debian — adjust package commands for other distros)
  • Privileges: Root or sudo required — this skill modifies system-wide security config
  • Pre-check: Verify you have SSH key-based access before disabling password auth

⚠️ All commands below modify system configuration. Confirm with the user before running each section. Do not run these automatically without explicit approval.

SSH — Key-Only Auth

Disables password authentication. Ensure key-based SSH works first or you will be locked out.

sed -i 's/^#*PermitRootLogin.*/PermitRootLogin prohibit-password/' /etc/ssh/sshd_config
sed -i 's/^#*PasswordAuthentication.*/PasswordAuthentication no/' /etc/ssh/sshd_config
systemctl restart ssh

Firewall — Deny All Except SSH

ufw default deny incoming
ufw default allow outgoing
ufw allow ssh
yes | ufw enable

Add more rules as needed (e.g. ufw allow 443 for HTTPS).

Fail2ban — Brute-Force Protection

Installs fail2ban via apt (Debian/Ubuntu). Adjust for other package managers.

apt-get install -y fail2ban
systemctl enable --now fail2ban

Default config protects SSH. For custom jails: /etc/fail2ban/jail.local.

OpenClaw Credentials

chmod 700 ~/.openclaw/credentials

OpenClaw Gateway Service (optional)

Creates a systemd service for auto-restart on reboot. Runs as root — review the service file before enabling.

cat > /etc/systemd/system/openclaw-gateway.service << 'EOF'
[Unit]
Description=OpenClaw Gateway
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
ExecStart=/usr/bin/env openclaw gateway
Restart=always
RestartSec=5
User=root
WorkingDirectory=/root/.openclaw
Environment=HOME=/root
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload && systemctl enable openclaw-gateway

Verify

ufw status                                    # active, SSH allowed
systemctl is-active fail2ban                  # active
grep PasswordAuthentication /etc/ssh/sshd_config  # no
stat -c %a ~/.openclaw/credentials            # 700
systemctl is-enabled openclaw-gateway         # enabled

Lessons

  • On Ubuntu, SSH service is ssh not sshd
  • AWS security groups provide network-level filtering but UFW is defense-in-depth
  • Always verify key-based SSH access before disabling password auth
  • The gateway service is optional — only needed if OpenClaw should survive reboots

Host Hardening v1.0

Author: ppiankov

Copyright © 2026 ppiankov

Canonical source: https://clawhub.com/skills/host-hardening

License: MIT

This tool follows the Agent-Native CLI Convention. Validate with: clawhub install ancc && ancc validate .

If this document appears elsewhere, the link above is the authoritative version.

版本历史

共 3 个版本

  • v1.0.5 当前
    2026-03-29 04:42 安全 安全
  • v1.0.4
    2026-03-26 21:31
  • v1.0.1
    2026-03-07 01:58

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

developer-tools

Context Hygiene

ppiankov
OpenClaw 代理的推理卫生协议——通过将探索压缩为决策、执行文件预算以及剪除残余上下文,保持上下文清晰。
★ 0 📥 1,153
security-compliance

OpenClaw Backup

alex3alex
备份与恢复 OpenClaw 数据。适用于创建备份、设置自动备份计划、从备份恢复或管理备份轮转。处理 ~/.openclaw 目录归档并包含适当的排除规则。
★ 89 📥 30,584
security-compliance

Skill Vetter

spclaudehome
AI智能体技能安全预审工具。安装ClawdHub、GitHub等来源技能前,检查风险信号、权限范围及可疑模式。
★ 1,210 📥 266,142