6.1 KiB
Adopting a host
Goal: describe a machine read-only before anyone writes Salt for it. The probe (probe/hostprobe.py) collects facts;
the operator tool hub profile / hub suggest (see docs/cli.md) turns them into inventory groups, pillar and a checklist.
You can also run the probe by hand (below) and read the JSON.
Flow
- Add the host to
hosts(address, user, port,syslog_hostname). hub profile <host>: runsssh [-p port] user@address python3 - < probe/hostprobe.pyand stores the JSON (see docs/cli.md). By hand:ssh user@address python3 - < probe/hostprobe.py > profile.json.hub suggest <host>: groups, pillar forsecurity_hub:audit:hosts:<host>, blockers and candidates (see docs/cli.md).- Resolve blockers (address, sudo, sshd AllowUsers drop-in, minion id, hostname) and decide on candidates.
- Paste the reviewed pillar into
pillar/security_hub/init.sls. - Run
playbooks/salt_onboard_host.yml(dry run first). - Re-profile later (
hub profileagain,hub profile-diff): a changed machine-id or host key means the host was rebuilt; new or removed containers, ports, units or changed script hashes are drift.
What the probe reads
Only what each section needs, with sudo -n (never prompting) and only if sudo -n true succeeded. No installs, no
writes (not even a temp file), 60 s total, 15 s per command, 2 MiB output.
| Section | Reads |
|---|---|
| identity | /etc/hostname, /etc/os-release, /proc (osrelease, cpuinfo, meminfo, uptime), statvfs of /, systemd-detect-virt, sha256 prefix of /etc/machine-id, /etc/ssh/ssh_host_*.pub (fingerprints), ip -o addr show dev tailscale0 |
| access | current user and groups, sudo -n true (boolean), sudo -n sshd -T reduced to AllowUsers/AllowGroups/PasswordAuthentication/PermitRootLogin/Port (fallback: sshd_config.d file names), systemctl is-active for fail2ban/ufw/nftables |
| software | package manager, unattended-upgrades (dpkg-query + timer state), docker version server version, salt-minion version/state and only the id: and master: lines of /etc/salt/minion and minion.d/*.conf, python3 version |
| containers | docker ps -a -q --no-trunc then docker inspect --format <fixed template>: name, compose project/service/working_dir labels, image, user, privileged, state, health, restart policy, published ports. The template never requests Env, Cmd, Mounts or other labels. Health is read with index .State "Health" because Docker 29 omits the key without a healthcheck. |
| services | regular unit files in /etc/systemd/system, reduced to exec paths, User, Group, OnCalendar, timer Unit, Description; systemctl is-enabled/is-active |
| candidates | for exec paths of non-hub units under /srv, /opt, /usr/local, /home: owner, group, mode, size, sha256 of the file |
| listening | ss -H -lntup (process names need sudo -n) |
| cron | file names in /etc/cron.d; whether user crontabs exist (boolean) |
What it never reads
Environment variables (the probe passes subprocesses a two-variable environment), .env files, private keys,
certificates, tokens, password databases, sudoers, shell history, /proc/*/environ, unit Environment= lines or
command arguments, script contents (hashed only), cron contents, container env/cmd/mounts. A path guard refuses such
names before any open; a secret-looking script name is listed with sha256: null instead of being read.
Anything that could not be read lands in unreadable with a reason; the probe never fails as a whole because of one
collector. The one cost of sudo -n: a host without passwordless sudo logs one failed sudo attempt in its auth log.
Output schema (schema 1, the contract for the Go tool)
One JSON line on stdout: {schema, probed_at, sections, unreadable}. probed_at is UTC YYYY-MM-DDTHH:MM:SSZ.
unreadable is a list of {section, item, reason}. Lists are sorted. null means not determinable.
identity:hostname,os{id,version_id,version_codename,pretty_name},kernel,arch,cpus,mem_total_kb,root_disk{total_bytes,used_percent},virtualization(null if unknown, "none" on metal),uptime_s,machine_id_sha256_prefix(16 hex),ssh_host_keys[{type,fingerprint "SHA256:..."}],tailscale0[address].access:user,groups,sudo_nopasswd,sshd{source, allowusers, allowgroups, passwordauthentication, permitrootlogin, port[]}wheresourceis"sshd -T", or"sshd_config.d names"(thenallowusersandallowgroupsarenull= unknown andconfig_d_fileslists names), or null;fail2ban,ufw,nfteach{installed, active}.software:package_manager,unattended_upgrades{installed,timer_enabled},unattended_upgrades_enabled,docker_server_version,salt_minion{installed,version,active,id,master},python3.containers[]:id(12 hex),name,project,service,working_dir(compose labels, "" if none),image,user("" = image default, treat as root),privileged,status,health("" = no healthcheck),restart_policy,ports[{container_port,proto,host_ip,host_port}](sorted by host port).services[]:name,kind(service|timer),enabled,active,exec_paths[](absolute paths only),user,group,on_calendar[],unit(timer target),description,hub_managed(name startssecurity-hub-).candidates[]:path,unit,sha256,owner,group,mode(octal string),size, optionalnote.listening[]:proto,address,port,process(null without sudo -n).cron:cron_d[],user_crontabs(bool or null).
Examples: probe/fixtures/expected-alpha.json and expected-beta.json (invented fixture hosts: alpha has Forgejo compose projects forgejo and forgejo-onion, AllowUsers admin, a root:root
update-forgejo.sh; beta has the challenges project with lab-a, lab-b, lab-c, lab-d). Addresses, hosts, users, hashes and sizes are invented documentation values.
Re-profiling
Keep each profile. A different machine_id_sha256_prefix or ssh_host_keys set means a rebuild: re-verify the host key
out of band, then redo sudo, sshd drop-ins and the minion key. Added or removed containers, listening ports and units,
and changed candidate hashes show drift against the pillar and baselines.