Your Deploy Only Needs Root to Restart: How Far Can You Shrink the Agent's Privileges?
Keep the deploy agent unprivileged and hand only the service restart to a small helper that checks the approved plan. The four things the helper must verify, why a restart approval needs a service name, and which records to keep per step.
List what a deploy agent actually does, in order. It polls for a job, downloads the artifact, checks the version, and reports the result. In some Linux environments the only step that needs elevated privileges is the final restart of the portal service. So how much privilege does the long-running process handling everything else really need?
Give the always-on deploy agent nothing beyond a regular account, and let a separate helper that checks the approved plan perform the one privileged action, the restart. Privilege can then be explained service by service.
What does it look like to carve out only the restart?
Start by checking whether the OS can delegate management actions for a specific service. In systemd, for example, restarting a service is a management action subject to an authorization check. If your policy calls for a dedicated helper, the unprivileged agent prepares the release and a small local program, the helper, validates approved restart requests.
[Unprivileged agent]
│
▼
[Stage the approved artifact in a pending path]
│
▼
[Helper checks caller against the approved plan]
│
├── server, service, version, action match ──▶ [Restart registered service] ──▶ [Confirm running version]
│
└── mismatch or expired ─────────────────────▶ [Refuse and record the reason]A restart approval needs a service name
Approval R-42 authorizes "start portal build 218 on production server A." What happens if someone presents that same approval number and asks to restart the settlement service? Checking that the approval number is valid isn't enough to tell the two requests apart.
The helper should verify who made the request, whether this server is in scope, whether the staged file matches the approved artifact, and which service's restart is actually permitted. Service names map to entries registered by operations, and the right to change the helper binary and the service definitions is managed separately. If the ordinary deploy account can freely edit the config that decides what gets restarted, per-service privilege becomes hard to defend. Splitting accounts per service on the same host continues in Why two services on one server should deploy under different accounts.
Which records should exist when you review it?
The review should show three separate records: artifact staged, permission check refused, running version. Show two requests back to back under the same approval. The portal restart leaves the build number that actually started. The settlement restart leaves a refusal reason.
In the second case, the portal artifact may already be sitting in the pending path. If the operations log only says "failed", the next person has to start by figuring out whether the file needs to be sent again. Keeping the three records apart tells them where to resume.
- #deployment
- #security
- #least-privilege
- #linux
- #on-prem