VPS security checklist for AI agents
Last checked 17 Nov 2026
Nine things to do on a new VPS before you run OpenClaw, Hermes or Claude Code. The commands are for Ubuntu, and each step links to the official page it comes from. It's a starting point, not a full security audit.
SSH keys only, password login off
Make a key on your own computer and copy it to the server. Then turn off password login in
/etc/ssh/sshd_config.ssh-keygen -t ed25519 ssh-copy-id username@your-server # on the server, in /etc/ssh/sshd_config: PasswordAuthentication no sudo sshd -t sudo systemctl restart ssh.serviceAlso check the files in
/etc/ssh/sshd_config.d/. Ubuntu reads them first, and OpenSSH uses the first value it finds, so a setting there can override yours.Keep your current session open and test a new login with the key before you log out.
Source: Ubuntu OpenSSH server, sshd_config manual
Use a normal user with sudo, not root
Create your own user, add it to the
sudogroup and copy your key to it. Once that works, stop root logging in over SSH. Hermes says never to run its gateway as root.sudo adduser yourname sudo adduser yourname sudo # in /etc/ssh/sshd_config: PermitRootLogin no sudo sshd -t sudo systemctl restart ssh.serviceThen open a new terminal and check that logging in as root is refused.
Source: Ubuntu user management, Ubuntu OpenSSH server, sshd_config manual, Hermes security
Turn on the firewall, allowing SSH first
ufw is off by default on Ubuntu. Allow SSH before you enable it, or you can lock yourself out. Only open other ports you actually need.
sudo ufw allow 22 sudo ufw enable sudo ufw statusSource: Ubuntu firewall
Keep automatic security updates on
Ubuntu installs security updates daily with
unattended-upgrades, which is installed by default. Check both values below are"1"in/etc/apt/apt.conf.d/20auto-upgrades. If the package is missing, install it.APT::Periodic::Update-Package-Lists "1"; APT::Periodic::Unattended-Upgrade "1"; sudo apt install unattended-upgradesSource: Ubuntu automatic updates
Keep agent gateways and dashboards off the internet
OpenClaw's gateway listens on loopback (port 18789) by default, and its docs say to keep it that way unless you're sure. Container images are the exception, as they default to an exposed bind. Reach it from your laptop with an SSH tunnel, or with Tailscale Serve, which only shares it inside your own tailnet. Don't use Tailscale Funnel for this, because Funnel is public.
ssh -N -L 18789:127.0.0.1:18789 user@gateway-hostHermes's messaging gateway turns away anyone not on an allowlist or paired by default. Leave it that way.
Source: OpenClaw remote access, OpenClaw security, OpenClaw and Tailscale, Tailscale Serve, Hermes messaging
Lock down API key files and never commit them
Keep keys in the agent's env or config file, readable only by you. Never commit
.envfiles to a repo. In Claude Code you can also stop it reading.envfiles with a deny rule in~/.claude/settings.json.chmod 600 ~/.hermes/.env chmod 700 ~/.openclaw chmod 600 ~/.openclaw/openclaw.json{ "permissions": { "deny": ["Read(./.env)", "Read(./.env.*)"] } }Source: Hermes security, OpenClaw secrets and storage, Claude Code settings
Set a spend limit on your model API key
An agent left running can spend a lot. In the Claude Console you can set a monthly spend limit below your tier's cap, under Settings, Spend limits. You can also give the agent its own workspace with its own limit. You can't set one on the default workspace. If you use another provider, check whether it has a similar setting.
Source: Anthropic rate and spend limits
Have backups and snapshots
Check whether your host offers snapshots or automatic backups, and what they cost. Take a snapshot before big changes. If you copy an agent's folder off the server, keep the copy private. OpenClaw says to assume anything under
~/.openclaw/may contain secrets.Source: OpenClaw secrets and storage
fail2ban (optional)
fail2ban watches log files and bans IP addresses with too many failed logins for a set time. With password login off, it's an extra layer rather than a must. Its own docs say it can't remove the risk of weak authentication, so do step 1 first.
Source: fail2ban
Once the server is locked down, check which plan suits your agent or compare plans by price.
Get the price changes by email
One short email a week: what got cheaper, what got dearer, and anything I got wrong. Free, unsubscribe any time.
Form not loading? Subscribe on beehiiv.