system-user-conventions
Skill7 starsChanged 3 days agoMITView on GitHub
Unix service accounts, groups, ownership and modes. TRIGGER when: creating or reviewing an account or group (`useradd`, `groupadd`, `sysusers.d`, cloud-init `users:`, Ansible `user`, `Dockerfile` `USER`); granting sudo or a group; setting ownership or modes on service files; SSH access or a deploy/CI account; user asks who a process runs as. SKIP when: no account, group, ownership or login is involved.
- Reads credentials
- Deletes or force-pushes
1 other project uses a version of this.
Adopted by
Most recently taken up by
- leroyguillaume/skillsword for word, first seen Nov 22, 2026
Other versions1 project uses a version of this.
Word for word · 1
- leroyguillaume/skills★ 7100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository54 other files it gives its agents.
- adr-conventionsSkill
- api-conventionsSkill
- architecture-conventionsSkill
- argocd-conventionsSkill
- ci-conventionsSkill
- config-conventionsSkill
- contributing-conventionsSkill
- councilSkill
- cryptography-conventionsSkill
- dependency-update-conventionsSkill
- diagram-conventionsSkill
- docker-conventionsSkill
- documentation-conventionsSkill
- frontend-conventionsSkill
- github-actions-conventionsSkill
- github-issue-conventionsSkill
- github-pr-conventionsSkill
- github-repo-settingsSkill
- gitlab-ci-conventionsSkill
- helm-conventionsSkill
- herdr-core-delegationSkill
- herdr-delegationSkill
- herdr-tui-delegationSkill
- kopf-conventionsSkill
- kubernetes-operator-conventionsSkill
- logging-conventionsSkill
- logo-conventionsSkill
- mise-conventionsSkill
- ollama-conventionsSkill
- openssf-conventionsSkill
- pr-conventionsSkill
- pre-commit-conventionsSkill
- project-metadata-conventionsSkill
- python-async-conventionsSkill
- python-conventionsSkill
- readme-conventionsSkill
- release-script-conventionsSkill
- release-supply-chain-conventionsSkill
- renovate-ci-conventionsSkill
- rest-conventionsSkill
- rust-build-conventionsSkill
- rust-conventionsSkill
- rust-http-conventionsSkill
- security-policy-conventionsSkill
- signal-handling-conventionsSkill
- sql-conventionsSkill
- starlight-conventionsSkill
- systemd-conventionsSkill
- task-conventionsSkill
- terraform-conventionsSkill
- topic-splittingSkill
- ui-copy-conventionsSkill
- web-layout-conventionsSkill
- yaml-conventionsSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 0 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 27
One account per service, named after the app: Never a shared catch-all (www-data running three apps means a bug in one reads the secrets of …
- Very specific: line 111
Never an interactive adduser in a runbook: it prompts, so it cannot be automated, and it silently defaults to a real shell and a /home …
- Very specific: line 131
chown -R myapp /opt/myappis not a fix: When a permission error shows up, find the single path that must be writable and grant that one — …
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
System user conventions
A service account exists so that a compromised process is stuck being that process: it cannot log in, cannot be logged into, cannot become anything else, and owns nothing it does not strictly need. Every property below removes one way out of that box — which is why "it was easier with a shell" is never a reason.
The unit-file side of this (User=, DynamicUser=, the sandboxing block)
lives in systemd-conventions; the container side (UID/GID 65532, distroless
nonroot) in docker-conventions. This skill is the account itself, wherever
it is created.
The account
- One account per service, named after the app. Never a shared catch-all
(
www-datarunning three apps means a bug in one reads the secrets of the other two), and never a human's account. - Never
nobody/nogroup(65534). It is shared by every unmapped process on the box and is what NFS squashes root to, so "owned bynobody" effectively means "owned by everybody". Same reasoning as avoiding it in containers. --system: a UID from the system range (100–999 on Debian/RHEL), no password aging, no expiry, not counted as a login account. In a container image the number is different on purpose — UID/GID 65532, seedocker-conventions— because a container UID is a host UID.- Shell
/usr/sbin/nologin(/sbin/nologinon RHEL and Alpine). It refuses the session and exits non-zero, which kills interactive SSH,su -, andssh host command— everything goes through the login shell. Prefer it to/bin/false, which does the same thing silently and leaves the user wondering. Never/bin/bash"for debugging": to get a shell as the service account, usesudo -u myappon a specific command,runuser -u myapp -- …, orsystemd-run --uid=myapp --pty …. None of those need the account to have a shell of its own. - Password locked, never a hash, and never an empty field — an empty
second field in
/etc/shadowis a passwordless account, which some PAM stacks happily accept.passwd --lock/lock_passwd: true/password: '!'all write the!that means "locked". Caveat worth knowing: locking the password does not block SSH key auth.nologinplus an empty~/.ssh/authorized_keysis what closes that door. - Home is the state directory, or nothing. Point it at the state
directory the service already has (
/var/lib/myapp, created by systemd'sStateDirectory=, not byuseradd -m); with no state directory, home is/nonexistentand none is created. Never/home— it is for humans, is frequently a separate or NFS-mounted filesystem, anduseradd -mcopies/etc/skeldotfiles nobody will ever read. Never/etc/myapp— config is root-owned, and a home there is how it ends up chowned to the service. - No sudo, no
wheel, noadm. And specifically nodockergroup: a member can rundocker run -v /:/host, which is root with extra steps.lxdandlibvirtare the same trap. Adding a service account to any of them undoes every other line on this page. - Supplementary groups only for a resource the service must actually
reach, one group per shared resource (
myappincertsto read a TLS key). Not "because it was the quickest way to fix a permission error".
Create it declaratively
Provisioning that runs useradd imperatively has to answer "what if it
already exists?" — useradd exits 9 when it does, so the script fails on the
second run. Every form below is idempotent by construction:
systemd-sysusersis the default on a systemd host or in an image —/usr/lib/sysusers.d/myapp.confwhen a package or image ships it,/etc/sysusers.d/myapp.confon a hand-provisioned host; applied at package install and at boot:#Type Name ID GECOS Home dir Shell u myapp - "myapp service" /var/lib/myapp /usr/sbin/nologincloud-init, when the account comes up with the machine. Keep
- defaultfirst: ausers:list without it skips the distro's default user, and top-levelssh_authorized_keysthen lands on no account:users: - default - name: myapp system: true shell: /usr/sbin/nologin lock_passwd: true homedir: /var/lib/myapp no_create_home: true- Ansible:
ansible.builtin.userwithsystem: true,shell: /usr/sbin/nologin,home: /var/lib/myapp,create_home: false,password: '!'. Dockerfile:useradd --system --uid 65532 --gid myapp --shell /usr/sbin/nologin --home /nonexistent --no-create-home myapp(full form and rationale indocker-conventions).A shell script, only when nothing above fits — and then guarded:
id -u myapp >/dev/null 2>&1 || useradd --system \ --shell /usr/sbin/nologin --home-dir /var/lib/myapp --no-create-home myapp
Never an interactive adduser in a runbook: it prompts, so it cannot be
automated, and it silently defaults to a real shell and a /home directory.
What the account owns
The account's privileges are not only in /etc/passwd — they are in the file
modes around it.
| Thing | Owner | Mode | Why |
Binary, /usr/local/bin/myapp | root:root | 0755 | A service that can write its own binary rewrites it after a compromise and survives every restart |
Unit file, timers, /etc/systemd/** | root:root | 0644 | Writing them is a direct path back to root |
Config directory, /etc/myapp/ | root:root | 0755 (what ConfigurationDirectory= creates) | Holds nothing secret itself; the files' modes guard their content |
Config files, /etc/myapp/* | root:myapp | 0640 | Readable by the service, writable by nobody but root |
| Secret file | root:root, or root:myapp when the service opens it itself | 0600, or 0640 | LoadCredential= and EnvironmentFile= are read by PID 1 — see systemd-conventions |
State, /var/lib/myapp/ | myapp:myapp | 0700 (StateDirectoryMode=0700; the default is 0755) | The one place it writes |
Runtime, /run/myapp/ | myapp:myapp | 0700 (RuntimeDirectoryMode=0700) | Sockets and PIDs; wiped on stop, so nothing stale survives a restart |
Cache, /var/cache/myapp/ | myapp:myapp | 0700 (CacheDirectoryMode=0700) | Disposable, but its content is still the service's own |
Logs, /var/log/myapp/ | myapp:myapp | 0700 (LogsDirectoryMode=0700) | Own log files; the rest of the box has no need to read them |
chown -R myapp /opt/myappis not a fix. When a permission error shows up, find the single path that must be writable and grant that one — usually it turns out to be aStateDirectory=that was missing.chmod 777is never the answer, in any script, ever. If two accounts must share a directory, that is a group plus2770(setgid so new files inherit the group), not world-writable.UMask=0077in the unit's hardening block (systemd-conventions), so whatever the app creates at runtime is not readable by the rest of the box by default.
Humans are the mirror image
- One account per person, never a shared
admin/deploy/opslogin. A shared account has no audit trail:sudologs "admin ranrm -rf", and the machine has no idea which of the six people that was. - Real shell, key-based SSH only (
PasswordAuthentication no,PermitRootLogin no), sudo through a group (wheel/sudo), not a per-usersudoersline.NOPASSWDonly where the workflow genuinely cannot prompt, and scoped to the commands that need it. - A CI or deploy account that must accept SSH is the one exception to
nologin— it needs a shell to run the command. Constrain it instead: a forced command and lockdown options inauthorized_keys(restrict,command="/usr/local/bin/deploy"), no sudo, no interactive session, and its own key per pipeline so a single key can be revoked. - Removing someone is removing the account, not just their key — and their group memberships go with it.
Audit what is actually on the box
Cheap checks worth running when you inherit a machine or finish provisioning one:
# accounts that can actually log in
awk -F: '$7 !~ /(nologin|false)$/ {print $1, $3, $7}' /etc/passwd
# unlocked passwords: hash not starting with ! or * (run as root)
awk -F: '$2 !~ /^[!*]/ {print $1}' /etc/shadow
# empty password field — passwordless login on a permissive PAM stack
awk -F: '$2 == "" {print $1}' /etc/shadow
# who holds root-equivalent group membership
getent group sudo wheel adm docker lxd libvirtAnd the one that matters most after a deploy: systemctl show myapp.service
-p User -p Group — the account the service actually runs as, rather than
the one the config says it should.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

