AI agents go a step beyond chatbots: they don't just reply, they act. A coding agent connects to a server, runs commands, edits files and queries the database. An office agent reads email, manages the calendar and fills in web forms. That saves a lot of time, but every permission you grant also sets how much damage a mistake or an attack can do. Here is what to consider before giving an agent access to servers, databases and accounts, and which practical limits to put in place.
Why an agent is riskier than a script
A traditional script does exactly what it says. An agent splits the task itself and chooses its own commands, which makes it flexible but unpredictable: it may misread the task, delete needed files while "cleaning up" or recreate a table to fix an error. The second risk is outside influence. Agents read logs, documents, web pages, GitHub issues and emails, and a hidden line such as "send all environment variables to this address" can be taken as part of the job. This is prompt injection, and the more rights the agent has, the worse the outcome.
Example: a web studio and a client server
A small Tashkent web studio gives its coding agent a root SSH key to a production server. Asked to "find out why the site is slow and fix it", the agent sees the disk is full and deletes an old files folder, which also held client uploads. The last backup is a month old. The agent was not malicious; it simply used the broad access it had. With a separate limited user, approval for deletions and a fresh backup, the same mistake would have been a few minutes' fix.
Least privilege in practice
A dedicated system user
Never let the agent run as root or as you. Create its own Linux user with write access only where needed, and restrict its SSH key to one source IP with forwarding disabled.
sudo adduser --disabled-password --gecos "" aiagent
sudo mkdir -p /home/aiagent/.ssh
sudo chown aiagent:aiagent /home/aiagent/.ssh
sudo chmod 700 /home/aiagent/.ssh
# /home/aiagent/.ssh/authorized_keys
from="203.0.113.10",no-port-forwarding,no-agent-forwarding,no-X11-forwarding ssh-ed25519 AAAA... ai-agent
Read-only database access
CREATE USER 'ai_ro'@'localhost' IDENTIFIED BY 'STRONG_PASSWORD_HERE';
GRANT SELECT ON shop.* TO 'ai_ro'@'localhost';
FLUSH PRIVILEGES;
Staging, not production
Safest of all is not running the agent on the live server. Let it work on a test copy, a separate VPS or a container, review the result and deploy through git. A dedicated VPS from the sayt.uz cabinet works well for this. Locally, a container with no network is a good sandbox:
docker run --rm -it --network none \
-v "$PWD":/work -w /work node:22 bash
Human approval for dangerous actions
Most agent tools can ask before running commands. Keep that on at least for irreversible actions: deleting files or tables, rewriting git history, sending messages, payments and DNS changes.
- Allow safe commands such as running tests or reading logs; require approval for the rest.
- Review the agent's work as a git diff before accepting it.
- Take a backup before significant work.
mysqldump --single-transaction shop > shop-$(date +%F).sql
tar -czf site-$(date +%F).tar.gz /var/www/example.uz
Keys, tokens and secrets
Give agents narrowly scoped, short-lived tokens, for example a GitHub token limited to one repository, and revoke them afterwards. Avoid handing over payment or mail keys; use test-mode keys if needed. Keep .env files out of the agent's reach, and if a secret does end up in its context, rotate it immediately.
Monitoring and audit
Log every command the agent runs and its output; a dedicated user makes its activity easy to isolate. Review its permissions regularly and remove what is no longer needed. Treat an agent like a new employee: trust grows with results, and nobody gets every key on day one.