AI agent VPS guide
Run an AI agent on a VPS.
A safe setup, step by step.
An AI agent is a program that uses an AI model to do jobs by itself: answer messages, sort email, fill in data, watch websites or run tasks on a schedule. On your own HostingBaba Linux VPS it keeps working while your own computer is off. This guide covers the server side: a separate user, a private dashboard, starting the agent again after a restart, and limits. Follow your agent's own guide for the install itself.
What customers run
Open-source personal agents such as OpenClaw, AI agent workflows in n8n (our n8n guide covers that install step by step), chat bots for Telegram, Discord or WhatsApp, and agents customers write themselves in Python or Node.js with an AI provider's API. You install and run the agent; we provide the server. HostingBaba is not affiliated with OpenClaw, n8n or any AI provider.
What you need
A Linux VPS with Ubuntu 24.04 LTS (choose it on the order form), SSH access from your own computer, and an API key from the AI provider your agent uses. An agent that calls a provider's API sends its requests to the provider's model, so the server mostly waits for answers. Our smallest VPS plan has 4 vCPU and 8 GB of memory. Check what your agent needs, watch memory use with free -h once it runs, and move to a bigger plan if it runs short. Agents that open web browsers, and several agents on one server, use more memory.
Our VPS plans have no graphics card. Running an AI model on the server itself, instead of calling a provider, needs much more memory and processing power; check the model's own requirements before you choose a plan.
Step 1: prepare the server
Log in over SSH as root with the details from your dashboard. Update the server and turn on the firewall for SSH. If you use a different SSH port, allow that one instead of OpenSSH. ufw enable warns that it may disrupt SSH connections; adding the SSH rule first prevents that in a normal setup. If you ever lock yourself out, the Launch console button on your server page opens the server's own screen in your browser.
apt update && apt -y upgrade
ufw allow OpenSSH
ufw enable
Create a separate user for the agent, so it runs without root rights. That limits what a mistake or a bad instruction can change. Do not add this user to the sudo or docker groups: membership of the docker group gives the same power as root.
adduser --disabled-password --gecos "" agent
Step 2: install the agent
Switch to the agent user and follow your agent's own install guide. Many agents need Node.js or Python; install the version the agent's guide asks for.
su - agent
Keep API keys in the agent's own settings file, or in a file only the agent user can read. Create it, then add one line per key in the form NAME=value, using the names your agent's guide gives:
touch ~/.env
chmod 600 ~/.env
nano ~/.env
Type exit to go back to root for the next steps.
exit
Step 3: keep the dashboard private
Many agents have a web dashboard or control page. Anyone who reaches it can control your agent, so set it to listen on 127.0.0.1 (the server itself), not on a public address, and do not open its port in the firewall. If the agent runs in Docker, publish its port as 127.0.0.1:8080:8080 rather than 8080:8080: ports published by Docker bypass the firewall (our Docker guide explains this and installs a current Docker version).
To use the dashboard, open an SSH tunnel from your own computer, keep that window open, and go to http://localhost:8080 in your browser. Replace 8080 with the port your agent uses:
ssh -L 8080:127.0.0.1:8080 root@YOUR.SERVER.IP
Check from your own computer that the port is not open to the internet: a browser visit to http://YOUR.SERVER.IP:8080 should not load. If the agent must be reachable from the internet, for example for webhooks, put it behind HTTPS as our n8n guide does with Caddy, and turn on the agent's own login and webhook secret or signature check: HTTPS on its own does not stop strangers sending requests.
Step 4: start it again after a restart
If your agent can install itself as a service, use that. Otherwise, as root, create a systemd service. In the file below, replace the folder and the ExecStart path with your agent's: ExecStart must be the full path of the command your agent's guide gives to start it, in a mode that stays in the foreground (not one that sends it to the background). If your agent keeps its keys in its own settings file instead of ~/.env, delete the EnvironmentFile line.
nano /etc/systemd/system/my-agent.service
[Unit]
Description=My AI agent
After=network-online.target
Wants=network-online.target
[Service]
User=agent
WorkingDirectory=/home/agent/my-agent
EnvironmentFile=/home/agent/.env
ExecStart=/home/agent/my-agent/start.sh
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
Start it, make it start when the server boots, and watch its log. If it keeps stopping, the log shows why; systemd gives up after several quick restarts in a row.
systemctl daemon-reload
systemctl enable --now my-agent
journalctl -u my-agent -f
Step 5: limits, safety and backups
Set a monthly spending limit with your AI provider, so a loop or a bug cannot run up a large bill. Give the agent its own accounts and only the access it needs, and have it ask you before it sends money, sends messages for you or deletes anything.
Web pages, emails and files your agent reads can contain hidden instructions meant to trick it. Treat what the agent reads as untrusted, and do not give it passwords or keys it does not need.
Keep the agent's settings, memory and data folder backed up off the server, for example with scp, and keep its software updated. We do not back up your server by default.
What is not allowed
Your server, and everything your agent does from it, must follow our Acceptable Use Policy. You are responsible for what your agent does. No spam of any kind, including automated messages, comments, sign-ups or posting links on other people's sites without permission, no getting around platform bans or fraud and detection systems, no phishing, no attacks and no scanning systems you are not allowed to test. Serious abuse such as phishing, malware, attacks or fraud stops the server at once; for other complaints you reply within 12 hours and fix it within 24 hours, or sooner if the case is urgent.