When should you use it?
- An agent helps with log searches, file inspection or database lookups
- You are tired of approving every repetitive read command
- MSPs letting agents troubleshoot client systems
Not for: Giving an agent production write access; Databases holding personal data without table-level restrictions or redaction
What do you need, and what do you get?
You need
- The systems the agent needs to read
- Your database engine and SSH setup
- Which tables or paths hold sensitive data
You get
- A least-privilege access plan
- Setup steps for read-only DB and SSH accounts
- A change process for anything that writes
How does it work, step by step?
- Create agent-only accountsA separate DB role and SSH user for the agent, never your own credentials.
- Make them read-onlyGrant SELECT on named tables only; restrict the SSH user's shell and file permissions.
- Enforce outside the agentUse database permissions, a restricted shell or a proxy, not instructions in a prompt.
- Route writes through reviewThe agent writes a script against a dev copy; a person reviews it in version control and runs it.
The prompt
Our own prompt, inspired by nico on Hacker News and written to work in Claude Code and Custom agent. Values in lime are placeholders.
Fill in the blanks (optional; the copied prompt uses your values)
Act as a security-minded systems engineer. I want an AI agent to help me investigate systems, but it must not be able to change anything. Environment: {systems} (database engine: {db_engine}; SSH hosts: {hosts}). Sensitive data lives in: {sensitive_locations}. Produce: 1) A least-privilege plan: a dedicated database role and a dedicated SSH account for the agent, with exactly what each may read. 2) The setup steps or SQL grants for {db_engine}, excluding the sensitive locations. 3) How to enforce the limits outside the agent (permissions, restricted shell, replica, proxy). Do not rely on telling the agent what not to do. 4) A change process: the agent drafts a script against a non-production copy, a person reviews it in version control and runs it. 5) Remaining risks, such as heavy queries, with a mitigation for each.
Inspired by nico on Hacker News: Ask HN: How do you safely give LLMs SSH/DB access?. The prompt above is written by playbooks.bot in our own words; nothing from the original is quoted.
What can go wrong?
- Command allowlists are easy to bypass: many CLI tools accept flags that write files or run other commands.
- Even read-only queries can slow a production database; use a replica and query timeouts.
Our take
This thread is useful because the replies are close to unanimous and come from people who run production systems. The question was about convenience; the answer was about blast radius. The pattern we would put in front of any MSP or IT team is simple: an agent gets its own identity with the smallest permissions that let it do the job, and the controls live in the database, the operating system or a proxy, not in a prompt. Writes become reviewed scripts that a person runs. That is slower, and several commenters said the trade is worth it. Our prompt turns the thread's advice into a plan you can apply to your own environment, and it refuses to recommend anything that relies on the agent behaving well. We tested it on a sample setup with a Postgres database holding a customer table and two Linux hosts; it produced read-only roles, kept the customer table out of scope, and pushed all changes into a review step.
Where the time goes back: Once the agent can only read, routine investigation runs without a click-to-approve on every command, and reviews focus on the few changes that matter.
FAQ
Is a list of approved commands enough?
What about personal data?
Source and credit
Inspired by nico on Hacker News. We describe the idea in our own words, link to the original, and wrote the prompt ourselves; nothing is quoted.
- Inspired by
- Ask HN: How do you safely give LLMs SSH/DB access?
- Creator
- nico on Hacker News
- Published on
- Hacker News
- Original date
- Jan 14, 2026
- License
- Not openly licensed (the poster keeps all rights), so we quote nothing and link to the original
- Originally for
- Claude Code
- AI dry run
- Oct 20, 2026: passed. Dry-run tested by our AI test agent on sample input. No reliance on allowlists in the prompt; sensitive tables excluded; write path goes through review.
AI dry run on sample data; not run with live connected accounts. The playbooks.bot test agent filled the prompt with synthetic inputs, produced the output and checked it against the page's stated outputs and guardrails. - Verified
- Oct 23, 2026: source link resolves to the original, the credited creator published it, our excerpt or prompt matches it, and the license allows our use.
Are you the creator? Claim or correct this page.