Safety rules when an AI works on your server

Claude Code and other AI assistants on your own server: installation, problems and fixes, safety rules.
rychy
Site Admin
Posts: 162
Joined: Tue Oct 20, 2026 10:45 am

Safety rules when an AI works on your server

Post by rychy »

🇧🇬 Прочети на български

An AI assistant on your server is like a new colleague with root access: fast, working around the clock and knowing a lot, but unfamiliar with your system and able to be confidently wrong. Here are the rules we work by with Claude Code. We learned most of them after something went wrong.

1. No passwords in the conversation

Do not type passwords, tokens or keys into the chat. Everything you write becomes part of the conversation.

If the assistant needs a key (for example for the Cloudflare API), the key lives in a file with permissions 600, owned by root, and is passed directly to the program without going through the screen:

Code: Select all

sudo cat /etc/myapp/api-token | python3 my_script.py
The script reads the key from stdin and never prints it.

2. Files with secrets are not opened, not even "filtered"

This is our most expensive lesson. The assistant was checking the mail server settings. To avoid showing passwords, it filtered the output itself:

Code: Select all

grep -v -i pass file   # "show everything except lines containing pass"
But in the sasl_passwd file, the password line does not contain the word "pass" at all. It looks like this: [server]:587 username:thepassword. The filter did not catch it and the password was printed on screen. It had to be changed, and it was yet another password change caused by mistakes like this.

The rule since then:
  • Files like sasl_passwd, .env, *token*, wp-config.php and private keys are not opened at all with cat, grep or a loop.
  • If something needs checking, only the specific field that cannot contain a secret is extracted. For example just the server: sudo cut -d' ' -f1 /etc/postfix/sasl_passwd.
  • A "filter that removes the secrets" (a blacklist) is not protection. It works until one line looks different.

3. A separate user with minimal rights

  • Do not run Claude Code as root.
  • Keep secret files as root:root 600. Then the assistant cannot read them without sudo, and you will see if it tries.
  • Give sudo only for the things that really need it.

4. Do not turn off the permission prompts

Claude Code asks before running a command or changing a file. The --dangerously-skip-permissions flag removes all prompts. The name says enough: do not use it on a server with real data. It is better to permanently allow only safe commands (reading, ls, grep in the code) and keep the prompt for everything else.

5. Read first, change later

For every problem, the assistant first looks and explains what it sees. It only makes changes after an explicit "yes". When you just want a check, say so: "check it, read-only".

6. A backup before every change

Database, configuration, page: first a backup, then the change, then a check. For us, every forum post goes through a database dump, and every site change through a copy of the file. That way any mistake can be undone in seconds.

7. Check the result, not the promise

"Done" means verified live: the page opens, the email arrived, the service runs.

A real example: the assistant wrote a script that sends a report by email. The mail server accepted the messages and the log looked fine. But the emails never reached the recipient. A rule in the mail server redirected all mail to a different mailbox. The assistant's first guess about the cause was wrong. The real cause only showed up when we checked where the emails had actually arrived.

8. Permission applies to one specific action

"Yes, delete this file" does not mean "delete whatever you decide". Deleting, restarting running services, publishing and payments: only with your confirmation at that moment. If the assistant suggests a next step, that step needs a new "yes".

And the other way round: if you say "stop, don't touch anything", that holds until you say otherwise.

9. Personal data stays with you

Emails, names and addresses of customers are not sent to outside services (APIs, search engines, online tools) unless you explicitly asked for it for a specific task.

In short

  • No passwords in the chat. Secrets in 600 files, passed straight to the program.
  • Files with secrets are not opened and not "filtered".
  • A separate user, no --dangerously-skip-permissions.
  • Read first, then change, with a backup and a live check.
  • Every risky action gets its own "yes".
We also keep these rules in CLAUDE.md: CLAUDE.md: how to give rules to your AI assistant. Installation: Claude Code on your own VPS. Have a rule of your own that you learned the hard way? Share it in this topic.

Return to “Claude Code and AI assistants on a VPS”