OpenClawd 安全地在VPS上部署,資安重要
安全地在 VPS 上部署:從全新的 Linux 例如:Ubuntu VPS 升級到加固型私有 AI 伺服器 1) 鎖定 SSH → 僅限金鑰,不使用密碼,不允許 root 登入。 sudo nano /etc/ssh/sshd_config # Set explicitly: PasswordAuthentication no PermitRootLogin no sudo sshd -t && sudo systemctl reload ssh 2) 預設拒絕防火牆 → 預設情況下阻止所有傳入連線。 sudo apt install ufw -y sudo ufw default deny incoming sudo ufw default allow outgoing sudo ufw enable 3) 暴力破解防護 → 登入失敗後自動封鎖 IP 位址。 sudo apt install fail2ban -y sudo systemctl enable --now fail2ban 4) 安裝 Tailscale → 您的私有 VPN 網狀網路。 curl -fsSL https://tailscale.com/install.sh | sh sudo tailscale up 5) 僅透過 Tailscale 進行 SSH 連線 → 不再公開暴露 SSH 服務。 # Verify Tailscale is working first! tailscale status sudo ufw allow from 100.64.0.0/10 to any port 22 proto tcp sudo ufw delete allow OpenSSH 6) Web 埠也設為私有 → 僅限透過您的裝置存取此應用程式。 sudo ufw allow from 100.64.0.0/10 to any port 443 proto tcp sudo ufw allow from 100.64.0.0/10 to any port 80 proto tcp 7) 停用 IPv6(可選) → 若不使用,可減少攻擊面。 sudo sed -i 's/IPV6=yes/IPV6=no/' /etc/default/ufw echo "net.ipv6.conf.all.disable_ipv6 = 1" | sudo tee -a /etc/sysctl.conf sudo sysctl -p && sudo ufw reload 8) 安裝 Clawdbot → 在您的私人伺服器上部署 AI 助理。 npm install -g clawdbot && clawdbot doctor 9) 將 Clawdbot 鎖定給所有者 → 只有你可以傳訊息給機器人。 { "dmPolicy": "allowlist", "allowFrom": ["YOUR_TELEGRAM_ID"], "groupPolicy": "allowlist" } 10) 修復憑證權限 → 不要讓秘密人盡皆知。 chmod 700 ~/.clawdbot/credentials chmod 600 .env 11) 執行安全審計 → 捕捉您遺漏的問題 —— 千萬別跳過! clawdbot security audit --deep 核實所有資訊: sudo ufw status ss -tulnp tailscale status clawdbot doctor 結果: ✅ 無公共 SSH ✅ 無公共 Web 端口 ✅ 伺服器只能透過 Tailscale 存取 ✅ 機器人只回覆你 ✅ 30 分鐘內即可擁有私人 AI 伺服器 現在你可以開始玩了,之前不行。 繫好安全帶再踩油門,懂嗎?