Dev.to Security 🔐 Cybersecurity 👁 0 📖 3 min read

I want my AI agents to read production logs without giving them SSH keys

I deal with a lot of infra, and I only want my agents doing things on production that I’ve explicitly allowed. Reading the last 100 lines of nginx logs is fine. I don’t want to babysit an agent while it does that. If it

I deal with a lot of infra, and I only want my agents doing things on production that I’ve explicitly allowed. Reading the last 100 lines of nginx logs is fine. I don’t want to babysit an agent while it does that. If it wants to restart nginx, I’d like to hear why first.

I tried to draw that line with SSH approvals. The rules I save in Codex don’t carry over to Claude Code. And when I asked Claude to run one health check on staging, the rule it offered to remember was ssh *. With my production key available, that would let the agent SSH into prod too.

I could approve every command individually. After the tenth log read, though, how closely am I going to read the eleventh prompt? I couldn’t write an SSH pattern I’d trust to mean “anything harmless on this machine.” I could write down the things I actually wanted the agent to do. That’s why I built Emisar.

What I’m willing to approve in advance

I wanted a list of actions, each with a risk level. Take two from Emisar’s Docker pack. With the policy I’d use for an investigation, here’s what happens when the agent calls them.

What the agent asks for Risk What happens
Read the last 100 log lines from the nginx container Medium The agent gets the logs and keeps investigating.
Restart that container High I get the host, the exact command and the agent’s reason. The restart waits.

“Restart nginx” tells me very little. I want to know what the agent found that a restart would fix. If all it can tell me is that the site is returning 502s, I’d rather it look at the upstream service first. If I do approve, I can approve just that restart. Later, whoever is on call can look up which host it ran on, who approved it and how it went.

Why I care about the arguments

A Codex user reported losing their Windows home directory during a cleanup. The agent tried to use $home for a temporary folder. PowerShell already uses that name for the user’s home directory. The assignment failed and the cleanup continued with the old value.

That’s why an Emisar action takes typed arguments. For docker.restart, the agent supplies a container name and an optional timeout. The runner checks the name against the pack’s allowed characters and the timeout against its range of 1 to 600 seconds. Then it passes those values directly to Docker. There’s no shell in that step to expand a variable. The agent could still pick the wrong container, which is why I want to see its name before a production restart.

What else I get out of this

My agents are a lot more useful when they can see production. If I ask why nginx is returning 502s, an agent looking at the repo can give me a list of possible causes. With access to the logs and container status, it can check whether the upstream container restarted when the errors began. I can ask a follow-up without copying another page of logs into chat.

That works from the cloud, too. I can connect Emisar to Claude and ask it to build a Claude artifact that shows which containers are down across the hosts I’ve given it access to. Or I can connect our Slack bot so the person on call can ask “What did nginx log in the last ten minutes?” right in the incident thread.

I manage access for the whole team in the Emisar control plane. I can give the Slack bot read access to production and let an on-call agent request a restart. If we change who can approve a restart, we change the policy once. It applies whether someone is using Claude, Codex or the bot.

There’s also a token benefit. Emisar exposes 14 MCP tools, even though the public catalog has 1,918 actions. When the agent needs nginx logs, it searches for that action and asks for its arguments. I can install the Postgres pack on the same host without spending tokens on Postgres tool descriptions every time I ask about nginx.

If you want to see what the approval looks like, try the nginx walkthrough on a dev host. You can leave the restart pending, check that nginx is still serving requests, then approve it and see the run in the audit log.

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.