How to host an AI agent on a VPS
An AI agent is a long-running process that holds API keys, keeps state and often waits for webhooks. A laptop goes to sleep and a serverless function hits its time limit, but a VPS keeps going. This guide covers the server side: how to keep the agent running, where to put its secrets, how to lock the server down, what to log and back up, and which plan fits. Setup for specific agents (Claude Code, OpenClaw, Hermes) lives on our AI-focused sister site aiserver.ee. Local models and RAG are covered in the guide “AI on your own VPS”.
At a glance
- One agent1-2 vCPUthe model runs at the provider
- RAM2-4 GBper agent; a local model needs more
- Uptimesystemdrestarts it after a crash
- Pricefrom €7.64/mo on annual billing, excl. VAT · C-XS

Contents11
- What an agent needs from a server
- First login: OS template and SSH key
- Keep it running: systemd or Docker
- API keys and other secrets
- Firewall, SSH and incoming webhooks
- Logs and memory limits
- Back up the agent’s state
- Email from the agent: rDNS and SMTP
- Which plan fits your agent
- Cost: a VPS plus an API, or a local model
- FAQ
What an agent needs from a server
Most agents are a Python or Node.js process that runs in a loop: read a task, call a model API, use tools, write the result somewhere. To the server that is an ordinary service, and it needs four things: a restart when it crashes, a safe place for API keys, disk for its memory, and a network that lets out what it needs and lets nothing else in.
The model itself usually runs at the provider. The agent on the VPS sends prompts and receives answers, so 1-2 vCPU and 2-4 GB of RAM is enough for one agent. A local model changes that picture completely; see the plan table below.
First login: OS template and SSH key
Pick a template in the VirtFusion panel. Debian 12, Ubuntu 24.04, AlmaLinux 9 and Rocky Linux all suit agents; Arch Linux, FreeBSD 14 and your own ISO are also available. Add your public SSH key in the panel and cloud-init places it on the server at first boot. You log in with the key, not with a password.
The templates are clean operating systems. Docker and Node.js are not preinstalled. Install the runtime your agent needs (Node.js, or the Python version and packages it expects) yourself, with root access. Then create a separate user for the agent (for example agent) and run the agent as that user, not as root. If the agent can execute shell commands, that user is what limits how much a bad prompt can break.
Keep it running: systemd or Docker
tmux or screen is fine for a first test, but an agent inside a tmux session does not come back after a crash or a reboot. For anything you rely on, use a systemd service. A short unit file with User=agent, WorkingDirectory, ExecStart, Restart=on-failure and WantedBy=multi-user.target in its [Install] section restarts the agent after a crash and sends its output to the system journal. systemctl enable --now agent starts it now and at every boot.
Docker suits an agent that ships with a Compose file or needs several services (the agent, a database, a headless browser). Set restart: unless-stopped so the containers come back after a reboot. One trap: a port published by Docker can bypass your ufw or firewalld rules. Publish internal ports on 127.0.0.1 only (for example 127.0.0.1:8080:8080) and put a reverse proxy in front. Use Docker 28 or newer: older versions left such ports reachable from other machines on the same network segment.
API keys and other secrets
Keep keys in a .env file outside the code repository, owned by the agent user and readable only by it (chmod 600). systemd reads it with EnvironmentFile=, Docker Compose with env_file. Add .env to .gitignore before the first commit: a key pushed to Git is a leaked key, even if you delete it in the next commit.
Give every agent its own API key and set a spending limit at the provider where one is offered. An agent stuck in a loop then burns a capped budget instead of your whole monthly bill, and you can revoke one key without stopping the others. If a key leaks, revoke it at the provider first and only then clean up the server.

Firewall, SSH and incoming webhooks
Turn off password logins: set PasswordAuthentication no and KbdInteractiveAuthentication no in the SSH configuration, reload sshd and check the result with sshd -T. Keep your current session open until a new key login works. Open only the ports you use: 22 for SSH, plus 80 and 443 if the agent receives webhooks. On Debian and Ubuntu ufw is the simplest tool, on AlmaLinux and Rocky Linux firewalld. An agent that only calls APIs needs no open port besides SSH.
For webhooks, let the agent listen on 127.0.0.1 and put Caddy or nginx in front with a Let’s Encrypt certificate. The proxy handles TLS and the agent never faces the internet directly. Verify the webhook signature or shared secret in the agent as well, because a public URL will be found.
If a firewall rule locks you out, the VNC console in the VirtFusion panel still opens the server, because it does not go through the server’s network. Set a local password for your admin user so the console can log in; SSH still accepts keys only. If the system no longer boots, Rescue Mode starts a Debian Live environment where you can mount the disk and fix the configuration.
Logs and memory limits
A systemd service writes to the journal: journalctl -u agent -f shows the live output. journald limits its own size by default; on a small disk, lower the cap with SystemMaxUse= in journald.conf. Docker’s default json-file log has no limit, so set max-size and max-file under logging in the Compose file, otherwise a talkative agent can fill the disk. Log the actions the agent takes and the errors it gets, not full prompts with customer data.
Agents leak memory more often than ordinary web services: long conversation histories, browser sessions that never close, embeddings kept in memory. Set a ceiling: MemoryMax= in the systemd unit, or a memory limit in the Compose file. When the agent hits it, the kernel stops the agent instead of the database or sshd, and Restart=on-failure or the Docker restart policy starts it again. RAM in our plans is guaranteed and not shared with neighbours. vCPU is shared, so give a CPU-heavy agent headroom rather than a plan sized to the edge.
Back up the agent’s state
An agent’s value sits in its state: the database or SQLite file, the vector store, memory files and configuration. The code is in Git; the state is not. Databases first get a consistent copy: pg_dump for PostgreSQL (pgvector included), and for SQLite sqlite3 state.db ".backup state-copy.db" instead of copying a file that is being written to. Then copy the dumps and files off the server on a schedule: restic to object storage or another server, borg to another server over SSH.
A manual restore point is included in every plan. Automatic backup is an add-on at €5 per month, excluding VAT. Treat them as an extra layer. The backup you can trust is the one you have restored at least once. Keep secrets out of the regular backup or encrypt it; restic encrypts by default.
Email from the agent: rDNS and SMTP
Agents often send reports and alerts. Mail sent straight from a new server IP has no reputation, so it lands in spam easily. If you still send directly, set rDNS (the PTR record) for the server’s IPv4 address in the VirtFusion panel to the hostname, and make sure that hostname’s A record points to the same address. Sign outgoing mail with DKIM and publish SPF and DMARC records for the domain.
Simpler and more reliable: send through an external SMTP service or an existing mailbox on port 587 with STARTTLS and a login. The agent then needs only an SMTP username and password in its .env file, and delivery becomes the mail provider’s job.
Which plan fits your agent
Size the server by what the agent does on it, not by how capable the model is. When the model runs at the provider, the server only orchestrates. What really uses RAM is a browser, Docker and a local model. After a week of real work, check with free -h and htop whether the agent needs more.
- One agent calling a model APIplanC-XSvCPU1 vCPURAM2 GB
- Several agents, Docker or a browserplanC-SvCPU2 vCPURAM4 GB
- An agent with a quantised 7-8B modelplanC-MvCPU4 vCPURAM8 GB
- Agents, a local model and a vector storeplanC-LvCPU6 vCPURAM16 GB
Cost: a VPS plus an API, or a local model
A VPS is a fixed monthly cost: C-XS from €7.64/month on annual billing, ex VAT. The model API is billed separately by its provider, per token, and hosting the agent on a VPS does not change that bill. What changes is everything around the model: state, logs and keys live on your server in Tallinn, and the agent keeps working when your laptop is off.
A local model removes the per-token bill but moves the cost into RAM. A quantised 7-8B model needs C-M (8 GB, from €31.49/month on annual billing) and answers at a few tokens per second on the CPU; measure it with your own prompts. Our plans have no GPU. Many setups use both: a local model for routine or private steps and an API model for the hard ones. The guide “AI on your own VPS” covers local models and RAG in depth.
FAQ
Can I host an AI agent on a VPS without a GPU?
Yes. Most agents call a model API, so the heavy computation happens at the provider and the VPS only runs the agent process, its tools and its state. A CPU-only VPS also runs small quantised local models (3-8 billion parameters) when it has 8 GB of RAM or more. Our plans have no GPU, so large local models and model training are not a fit.
How much RAM does an AI agent need on a VPS?
One agent calling a model API fits in 2 GB (C-XS). Several agents, Docker or a browser want 4 GB (C-S). An agent with a quantised local 7-8B model needs 8 GB (C-M), because the model weights and context sit in memory. RAM in our plans is guaranteed and not shared with other customers.
Should I run an AI agent with systemd or Docker?
systemd is the shortest path for a single Python or Node.js agent: one unit file, Restart=on-failure and logs in journald. Docker is the better fit when the agent ships with a Compose file or needs a database and a browser next to it. Both bring the agent back after a crash and after a reboot; tmux does neither.
Does my data stay private when the agent runs on a VPS?
The agent’s files, database, logs and keys stay on your server in Tallinn, under your root control. Prompts the agent sends to an external model API do leave the server and are processed under that provider’s terms. For data that must not leave the server at all, run a local model on the same VPS.
Is Docker or Node.js preinstalled on the server?
No. The templates (Debian 12, Ubuntu 24.04, AlmaLinux 9, Rocky Linux, Arch Linux, FreeBSD 14) are clean operating systems. cloud-init adds your SSH key at first boot. You install Docker, Node.js and the Python version your agent needs yourself, with root access.
What if a firewall rule locks me out of the server?
Open the VNC console in the VirtFusion panel. It reaches the server without depending on its network, so you can log in with your user’s local password and fix the rule. Set that password in advance; SSH can stay key-only. Without a password, or if the system does not boot, Rescue Mode starts a Debian Live environment for repairs.
One agent that calls a model API.