On this page
Key takeaways
- The user can read every file that other users may read, and a
.envfile with loose permissions is exactly such a file. - A separate key can be restricted, can be removed without touching your own access and shows up under its own user name in the log.
- The log shows when and from where it came in but not the commands, so ask the assistant at the end of the session for a list of every command it ran.
An AI assistant that can log in to your server can answer “why is it slow?” in a minute. It can also, by a misread instruction, delete things. The safe way to start is a user that can look but not touch: its own login, its own key, no sudo. This guide builds that user on Ubuntu 24.04, proves that it cannot change the system, other users’ files or settings and shows how to see what it did and how to remove it.
Before you start
You need an Ubuntu 24.04 server and a user with sudo, as in the first-hour guide, and an SSH client on your computer. The setup is yours to do, not the assistant’s: an assistant should never create its own access. The new user is called assistant here; use another name if you like and keep it in all commands.
If your assistant is a chat app and does not log in to the server, connect it with only the two “See” permissions (Advanced mode), as described in Connect an assistant.
- an Ubuntu 24.04 server and a user with sudo
- the address of the server, written here as SERVER_IP
- a few minutes at your own computer: you create a key there and test from there
The steps
Create a user without a password and without sudo
--disabled-password means nobody can log in to this user with a password, only with a key. The second command adds it to two groups that exist for exactly this: adm may read the log files in /var/log, and systemd-journal may read the system journal. id must list those two groups and neither sudo nor docker.
sudo adduser --disabled-password --comment "" assistant
sudo usermod -aG adm,systemd-journal assistant
id assistantNever add this user to the group sudo or docker. The group docker is equivalent to root: a user in it can start a container that mounts the whole disk.
Create a key for it on your computer
Run this on your own computer, not on the server. The empty passphrase (-N "") lets an assistant use the file without asking you; that is why this key must be restricted in the next step and never be used for anything else. The second command prints the public key, a single line you will paste in the next step.
ssh-keygen -t ed25519 -f ~/.ssh/assistant_myserver -C assistant-myserver -N ""
cat ~/.ssh/assistant_myserver.pubInstall the key with restrictions
Replace PUBLIC_KEY_LINE with the line you copied. The word restrict in front switches off everything the key does not need: no port forwarding, no agent forwarding, no graphical forwarding and no terminal. Commands still run, and a login with this key cannot be turned into a tunnel into your network. The rest creates the folder and the file with the permissions SSH insists on.
sudo install -d -m 700 -o assistant -g assistant /home/assistant/.ssh
echo 'restrict PUBLIC_KEY_LINE' | sudo tee /home/assistant/.ssh/authorized_keys > /dev/null
sudo chown assistant:assistant /home/assistant/.ssh/authorized_keys
sudo chmod 600 /home/assistant/.ssh/authorized_keysProve that it can look and cannot touch
Run all three from your computer. The first must print the user, the memory and the disk. The second must fail: the user has no sudo, so there is no password it could be asked for. The third must answer Permission denied: the user cannot write to /etc.
ssh -i ~/.ssh/assistant_myserver assistant@SERVER_IP 'id; free -h; df -h /'
ssh -i ~/.ssh/assistant_myserver assistant@SERVER_IP 'sudo -n true'
ssh -i ~/.ssh/assistant_myserver assistant@SERVER_IP 'touch /etc/should-not-work'Look for secrets that anyone can read
Read-only is not harmless. The user can read every file that other users may read, and a .env file with loose permissions is exactly such a file. This lists them under the places apps usually live. For every hit, tighten it with sudo chmod 600 FILE (and a matching owner) before you hand out the key.
sudo find /home /srv /opt /var/www -maxdepth 4 -name '.env*' -perm /004 -ls 2>/dev/nullTwo groups open the logs: adm reads the files in /var/log and systemd-journal reads the journal. Both hold login records (the addresses and user names of every login attempt), and the journal may also hold a secret that an app wrote into its log. Without both groups the assistant cannot read logs at all, so decide whether it needs logs; if not, leave both out of the second command.
Know what it can read
These are the reading commands an assistant needs for most questions: failed services, recent errors, disk, memory, listening ports and the busiest processes. All of them work without sudo. Anything outside this list it will report as denied, and that is the intended behaviour.
systemctl --failed --no-pager
journalctl -p err -n 50 --no-pager
df -h
free -h
ss -ltn
top -b -n 1 | head -n 15See what it did
The first command lists the logins of the user from the journal of the SSH service; the second reads the same events from /var/log/auth.log (if your server has that file). The log shows when and from where it came in but not the commands, so ask the assistant at the end of the session for a list of every command it ran. last assistant would stay empty here: the key has no terminal, so no session is written to the login records.
sudo journalctl -u ssh --since "1 hour ago" --no-pager | grep assistant
sudo grep assistant /var/log/auth.log | tail -n 20Take the access away
Do this when the session is over. Removing the key stops new logins, crontab -r removes any scheduled jobs the user set (it says no crontab if there are none), pkill -KILL ends running sessions at once and pgrep must print nothing before deluser --remove-home deletes the user and its folder; with a process still running, deluser fails. Create the user again next time; it takes a minute.
sudo rm /home/assistant/.ssh/authorized_keys
sudo crontab -r -u assistant
sudo pkill -KILL -u assistant
sleep 1
pgrep -u assistant
sudo deluser --remove-home assistantAsk an assistant for a health report
The setup stays yours; the assistant uses the access. Paste the prompt below into an AI assistant that can run SSH commands and give it the private key file of this user (the file assistant_myserver, not your own key). The prompt makes it list the commands first, run only commands that read, stop when something is denied and propose every fix as text for you to run.
If you also want an assistant to order, stop or delete servers, give it a Cloudvix API key, not your account login: keys have limits (up to €500 a month and 25 servers). Keep the two apart: this SSH user can look at one server, the API key can spend money. Tell the assistant to show you the price and wait for your yes before it orders anything.
I have given you read-only SSH access to my Ubuntu 24.04 server at SERVER_IP as the user assistant, with the key file ~/.ssh/assistant_myserver. You have no sudo and must not ask for it.
Task: write me a health report of this server covering disk space, memory and swap, failed services, errors in the journal from the last day, listening ports and the five busiest processes.
Rules:
1. Before you run anything, show me a numbered list of the commands you will run and wait for my yes.
2. Run only commands that read. Do not write, install, restart, kill or delete anything.
3. If something is denied, tell me and do not look for a way around it.
At the end, list every command you ran and what you found. For each problem, give me the fix as a command that I can run myself. Do not run it.The same with MCP: connect with only the two “See” permissions
If your assistant is a chat app, it does not need an SSH login at all. It can look at your Cloudvix account through the MCP server, and you decide what it may see. On the page where you connect it, choose Advanced and switch off everything except the two permissions that start with “See”: “See your account, servers, snapshots, SSH keys, plans and locations” and “See your balance and its history”. With those two it gets the tools that look: the price list, your servers, snapshots and SSH keys, your activity and your balance. It gets no tool that creates, changes or deletes. Connect an assistant shows the steps, and Permissions and limits explains every permission.
Add more only when you have a reason. Connect again with Standard access when you want the assistant to order, start or stop a server: it should show the price and wait for your yes before it orders. Switch on “Delete and reinstall servers” last, and only for a job that needs it: it starts off in Advanced mode. To give an assistant more or less, connect it again and choose other permissions. The SSH user in this guide is for an assistant that logs in to the server itself; the two ways do not replace each other.
Then try three questions, one at a time:
- Which servers do I have, and which of them are running?
- What is my balance, and what changed it in the last weeks?
- What would the smallest plan cost per hour and per month, excluding VAT?
If something goes wrong
Permission denied (publickey) when the assistant connects
Check the permissions SSH insists on: /home/assistant/.ssh must be mode 700 and authorized_keys mode 600, both owned by assistant. Read the reason in the server log: sudo journalctl -u ssh -n 20 --no-pager. Also check that the line starts with restrict ssh-ed25519 and holds the whole public key on one line.
journalctl says that no journal files were readable
The group membership applies to new logins only. End the session and connect again. If it still fails, run id assistant on the server and look for systemd-journal in the list.
The assistant cannot read a log file
The file does not belong to the group adm or has narrower rights, which is the intended limit. Let the assistant report it, and read the file yourself. Do not add sudo to solve it.
The assistant asks for sudo or a password
Say no and look at what it wants to do. Take the command it proposes, read it and run it yourself if it is right. For a task it has to do on its own, such as a deploy, give it one fixed command in a separate setup, as in the deploy guide.
Questions people ask
Is a read-only user really safe?
It is much safer than your own login, but not harmless. It cannot change the system, other users’ files or settings. It can read every file that other users can read, use the processor and the network, and write to its own home folder and /tmp, so it can fill them, and it can set its own crontab, a scheduled job that runs with the same limits. That is why the setup checks for readable secrets, and why you should remove the user, with its crontab, when the work is done.
Why a separate key and not mine?
Your key opens everything you can do. A separate key can be restricted, can be removed without touching your own access and shows up under its own user name in the log. If the file leaks or an assistant misbehaves, you cut off one key and not yourself.
Can the assistant fix the problem it finds?
Not with this access, on purpose. It can describe the problem and write the command, and you decide to run it. When you want an assistant to change one thing regularly, give it a single fixed command through a restricted key, as in the deploy guide, and nothing more.
Where to go next
When the assistant needs to change something, the next step is one fixed command through a restricted key, which the deploy guide builds. The agent-ready API guide explains what to look for before you give anything an API key. To connect a chat assistant with only the two “See” permissions, start at Connect an AI assistant.
Runs Cloudvix and is responsible for the guides published here.