⚡ Key takeaways
- Lock the front door first: key-only SSH, no root login, a firewall and fail2ban all survived the reboot tests.
- DNS over TLS needs more than one config file: my provider’s guest agent seems to rewrite
/etc/resolv.confat every boot, so I locked the file. - Run Hermes as a normal user with a Telegram bot of its own, and allow only your own user ID.
- Keep one root session open until
sudois proven. It saved me when a password that had worked suddenly did not.
Running an AI agent on your own server sounds easy until you remember that the agent can run commands. This Hermes Agent VPS guide follows a real build on a fresh Ubuntu 24.04 server: locked-down SSH, a firewall, encrypted DNS, Hermes Agent as a service and a Telegram bot that only you can talk to. I kept a log of every command and result, so you also get the mistakes.
Why run Hermes Agent on a VPS?
On your own PC, Hermes only works while the PC is on. A server fixes that: the bot answers at 3 a.m., scheduled jobs run while your laptop is closed, and the agent lives apart from your personal files. The price is an internet-facing machine that you secure yourself.
This is a follow-up for readers who know the basics from installing Hermes Agent on Windows 11. The safety advice in Secure Hermes Agent local mode applies here too, and matters more on a server.
What this Hermes Agent VPS setup includes
Hermes Agent is an open source AI agent by Nous Research. It can chat through Telegram, run scheduled jobs and execute commands on the machine it lives on. That last part is why the server matters: whoever can talk to the agent can, in effect, run code on your server. The plan is therefore security first, agent second.
You need:
- A VPS with Ubuntu 24.04 and the root password from your provider (I used Time4VPS).
- A Windows 11 PC with the built-in OpenSSH client. The steps are the same on macOS and Linux.
- A Telegram account.
- Roughly two hours.
I worked with an AI coding assistant that ran the commands over SSH and kept the log. I typed every password and token myself, so the assistant never saw one. Before you start, run free -h: mine reported 3.8 GiB of RAM, less than I had assumed, and the Hermes gateway alone uses 300 to 570 MB.
Step 1: create an SSH key and put it on the server
My PC had no SSH key at all. The first attempt to create one failed with Saving key ... failed: No such file or directory. On Windows, ssh-keygen does not create the .ssh folder when you pass your own path with -f, so create it first:
mkdir $env:USERPROFILE\.ssh ssh-keygen -t ed25519 -f $env:USERPROFILE\.ssh\id_ed25519
I pressed Enter at both passphrase prompts. Without a passphrase, scripts can log in without interaction, but so can anyone who reads the file. Use it for this one server only; ssh-keygen -p adds a passphrase later.
Then install the public key on the root account once. This is the only time you type the root password:
ssh root@YOUR_SERVER_IP "umask 077; mkdir -p ~/.ssh; echo 'YOUR_PUBLIC_KEY' >> ~/.ssh/authorized_keys"
On the first connection, ssh asks you to confirm the server’s fingerprint. Compare it with your provider’s web console, where ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub prints the real one. I skipped that check, so my first connection was trust on first use.
Step 2: update the server, add a sudo user and lock down SSH
Log in as root for the first part of this step, so the commands carry no sudo. A fresh image is older than you think: mine was an image from early 2025 with kernel 6.8.0-53. A plain apt upgrade held back the new kernel, so I used full-upgrade and rebooted once:
apt update && apt full-upgrade -y apt install -y ufw fail2ban unattended-upgrades git curl xz-utils reboot
Next, create a normal user, give it sudo and your key, switch on the firewall and add swap. The /etc/fstab line is what keeps the swap file after a reboot; without it, swapon only lasts until the next boot.
adduser --disabled-password --gecos "" youruser usermod -aG sudo youruser install -d -m 700 -o youruser -g youruser /home/youruser/.ssh echo 'YOUR_PUBLIC_KEY' > /home/youruser/.ssh/authorized_keys chown youruser:youruser /home/youruser/.ssh/authorized_keys chmod 600 /home/youruser/.ssh/authorized_keys ufw allow OpenSSH && ufw --force enable fallocate -l 2G /swapfile && chmod 600 /swapfile && mkswap /swapfile && swapon /swapfile echo '/swapfile none swap sw 0 0' >> /etc/fstab
Set that user’s password with passwd youruser. It is only used for sudo, because SSH password logins will be switched off.
fail2ban and automatic updates
fail2ban bans addresses that keep failing to log in. Ubuntu 24.04 writes the SSH log to the journal, so tell the jail to read from systemd. This allows 5 failures in 10 minutes and bans for an hour:
# /etc/fail2ban/jail.d/sshd-local.conf [sshd] enabled = true backend = systemd maxretry = 5 findtime = 10m bantime = 1h
Run systemctl enable --now fail2ban, then try one login for a user that does not exist and check fail2ban-client status sshd. The jail counted my attempt.
unattended-upgrades was already on: both lines in /etc/apt/apt.conf.d/20auto-upgrades should say “1”. It installs security updates but does not reboot; the file /var/run/reboot-required tells you when a kernel update waits.
Switch off root login and passwords
Ubuntu 24.04 reads /etc/ssh/sshd_config.d/*.conf in alphabetical order and the first value wins. My provider had already placed a 50-cloud-init.conf with PasswordAuthentication yes, so my file needs a name that sorts earlier:
# /etc/ssh/sshd_config.d/00-hardening.conf PermitRootLogin no PasswordAuthentication no
Run sshd -t to validate the syntax and systemctl reload ssh to apply it. Then test from fresh connections, from your own PC:
ssh youruser@YOUR_SERVER_IP # must work ssh root@YOUR_SERVER_IP # must fail: Permission denied (publickey) ssh -o PubkeyAuthentication=no youruser@YOUR_SERVER_IP # must fail as well
From here on you work as your normal user, so commands that need root get sudo.
Keep one root session open until sudo is proven. When I tested the reboot, sudo answered “Sorry, try again” three times, even though the same password had worked earlier. I never found out why. Because a root session from before the hardening was still open, I could reset the password with passwd youruser in seconds. Without it, I would have needed the provider’s web console.
Step 3: encrypt DNS with DNS over TLS
This step is optional hardening: your DNS lookups stop traveling in plain text. Ubuntu ships systemd-resolved, which can send DNS queries over TLS. I used Quad9:
# /etc/systemd/resolved.conf.d/99-quad9-dot.conf [Resolve] DNS= DNS=9.9.9.9#dns.quad9.net 149.112.112.112#dns.quad9.net 2620:fe::fe#dns.quad9.net 2620:fe::9#dns.quad9.net Domains=~. DNSOverTLS=yes
The empty DNS= line resets the list, so the provider’s servers do not stay on it. Before enabling this, check that outgoing port 853 is reachable from your server. Create the file with sudo mkdir -p /etc/systemd/resolved.conf.d and sudo nano, then run sudo systemctl restart systemd-resolved.
That was not enough. On my VPS, /etc/resolv.conf listed the provider’s plain DNS servers, and programs such as apt and curl read that file without asking systemd-resolved. After each reboot the file came back, a few seconds after the provider’s guest agent ran its network tool (prl_nettool). resolvectl query still reported “encrypted transport: yes”, because it goes through resolved itself. Test the path that programs really use, with getent hosts ubuntu.com.
My fix was to replace the file with a static one and make it immutable:
sudo rm /etc/resolv.conf sudo tee /etc/resolv.conf <<'EOF' nameserver 127.0.0.53 options edns0 trust-ad search . EOF sudo chattr +i /etc/resolv.conf
After a second reboot the file stayed intact, and ss -tn state established '( dport = :853 )' showed a connection to Quad9. To change DNS later, run sudo chattr -i /etc/resolv.conf first.
Step 4: install Hermes Agent
The installer is a shell script, and I read it before running it. At the time it was 1,302 lines long. Node.js needs libatomic.so.1, so install the package first:
sudo apt install -y libatomic1 curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash
In a normal SSH session the setup wizard starts straight after the install. If it does not, run hermes setup yourself. On my server the install took about 4.5 minutes and ended with Hermes Agent v0.23.0. A warning about cua-driver (a desktop control tool) is harmless on a headless machine.
For the terminal backend I chose Local: the agent runs commands directly on the server as your user, so it can do whatever that user can do. Never give it root, and keep the sudo password away from it.
My setup ended on a free model through Nous Portal instead of my own API key. You can change that later with hermes setup model. Finally, hermes doctor showed green checks for everything Telegram needs.
Step 5: connect Telegram, with a bot of its own
The full BotFather walk-through is in Hermes Telegram setup, based on the official Hermes docs. On a server, only a few things differ:
- Use a second bot. A bot token can be used by only one running Hermes at a time. I already ran a gateway on my PC, so I made a new bot with
/newbot. - Allow only your own numeric user ID. The wizard asks for “Allowed user IDs” and stores them as
TELEGRAM_ALLOWED_USERSin~/.hermes/.env. Never leave it empty: empty means open access. Pick the same ID as home channel, so scheduled results land in your private chat. - Prefer the manual route. The automatic route creates the bot through an onboarding service hosted by Nous Research. I could not verify what that service stores, and it timed out on me, so I created the bot with BotFather and pasted the token myself.
The gateway installs as a systemd user service. Enable lingering, or user services only run while you are logged in:
sudo loginctl enable-linger youruser hermes gateway status
After a reboot, the gateway was running again about 16 seconds after boot, without any manual start. Scheduled jobs work the same as on your PC; scheduling tasks in Hermes covers them.
Step 6: back up the agent
Hermes has a built-in hermes backup. It writes the whole Hermes home to one zip, and hermes import restores it. That zip includes .env and auth.json, so keep it offline and private. For nightly off-server backups I push the agent’s “brain” to a private GitHub repository, with a script that refuses to push when it finds a secret: Hermes Agent backup to GitHub, without leaking secrets.
Troubleshooting
sudo rejects a password you are sure about
Check the keyboard layout and what is in your clipboard, but do not assume the cause: in my case I never found it. If you still have a root session open, reset the password with passwd youruser. Otherwise you need the provider’s web console.
DNS goes back to the provider after a reboot
Something rewrites /etc/resolv.conf at boot. Check the journal around the time of its timestamp, then make the file a static, immutable file as described in step 3.
Conclusion
A Hermes Agent VPS is quick to set up and easy to get wrong. The value is in the checks: test the path programs really use, and keep a root session open until sudo works. Start with the SSH hardening in step 2, because everything else sits behind that door.
This article is part of the Agentic AI series.
The Tested Weekly
One email a week with the guides we tested, sources linked. No spam.