Linux over SSH: target-side setup
The SSH sensors (disk, load, memory, inodes, systemd and process) log in with a user name and a password or a key and run a few read-only commands. Nothing is installed on the target. This page sets up an account that can do that and nothing else.
1. A dedicated account
sudo useradd --create-home --shell /bin/sh --comment "Probeward monitoring" probeward
sudo passwd -l probeward # no password login; the key is the only way in
sudo install -d -m 700 -o probeward -g probeward /home/probeward/.sshThe account is in no group that grants anything (no sudo, wheel, docker, adm or systemd-journal) and has no sudo rule. None of the sensors needs more than an ordinary user: /proc/meminfo, /proc/loadavg, df, ps and systemctl show are readable by everyone.
Make a key pair for Probeward on any machine, and put the public half on the target:
ssh-keygen -t ed25519 -N '' -C probeward -f probeward_key
sudo tee /home/probeward/.ssh/authorized_keys < probeward_key.pub
sudo chown probeward:probeward /home/probeward/.ssh/authorized_keys
sudo chmod 600 /home/probeward/.ssh/authorized_keysStore the private key probeward_key in Probeward as a credential of kind ssh_key with the user name probeward, then delete your copy. A password credential (ssh_password) works as well; use a long random one, and leave PasswordAuthentication for this user on only if you need it.
2. Which commands run
Every command is preceded by echo probeward-begin; , so that a login profile that prints a banner cannot confuse the output. The sensors send exactly these:
| Sensor | Command |
|---|---|
ssh_disk | env LC_ALL=C df -Pk '<mount>' |
ssh_inodes | env LC_ALL=C df -Pi '<mount>' |
ssh_load | cat /proc/loadavg; getconf _NPROCESSORS_ONLN 2>/dev/null || grep -c '^processor' /proc/cpuinfo |
ssh_memory | cat /proc/meminfo |
ssh_systemd | env LC_ALL=C systemctl show --no-pager --property=LoadState,ActiveState,SubState -- '<unit>' |
ssh_process | env LC_ALL=C ps -eww -o rss=,pcpu=,args= 2>/dev/null || { echo probeward-busybox-ps; env LC_ALL=C ps -o rss=,args=; } |
| discovery | uname -sr, cat /proc/mounts, and two systemctl list-units and list-unit-files calls that only read |
The target needs a POSIX shell, env, df, ps (procps or BusyBox), cat, getconf or grep, and for the systemd sensor systemctl. Alpine and other BusyBox hosts work for the disk, inode, load, memory and process sensors (their ps has no CPU column, so the process sensor's CPU is unknown there). They have no systemd, so the systemd sensor says so and fails; watch their services with the process sensor. Recorded and live checks were made on Debian 13, Alpine 3.24 and Rocky Linux 10.
In an LXC container the load averages are those of the host that runs it, while the core count is the container's own, so the per-core load of a small container on a busy host reads high.
The only parameters that reach a command line are the mount point and the unit name. Probeward validates them (an absolute path without control characters; the characters systemd allows in a unit name) and wraps them in single quotes, with any single quote escaped. A process pattern is never sent: ssh_process always runs the same ps and filters its output itself.
3. Locking the account down
Allow only those commands. In /etc/ssh/sshd_config:
Match User probeward
AuthenticationMethods publickey
PermitTTY no
AllowTcpForwarding no
AllowAgentForwarding no
X11Forwarding no
PermitTunnel no
ForceCommand /usr/local/sbin/probeward-ssh-gateand the gate, /usr/local/sbin/probeward-ssh-gate (owned by root, mode 755):
#!/bin/bash
# Lets the Probeward account run the commands its sensors send, and nothing else.
cmd="$SSH_ORIGINAL_COMMAND"
mark='echo probeward-begin; '
path="'(/[A-Za-z0-9_./@+:-]*)'"
unit="'([A-Za-z0-9:_.@\\-]+)'"
allowed=0
case "$cmd" in
"${mark}cat /proc/loadavg; getconf _NPROCESSORS_ONLN 2>/dev/null || grep -c '^processor' /proc/cpuinfo" \
| "${mark}cat /proc/meminfo" \
| "${mark}cat /proc/mounts" \
| "${mark}uname -sr" \
| "${mark}env LC_ALL=C ps -eww -o rss=,pcpu=,args= 2>/dev/null || { echo probeward-busybox-ps; env LC_ALL=C ps -o rss=,args=; }" \
| "${mark}env LC_ALL=C systemctl list-units --type=service --state=running --no-legend --plain --no-pager; echo ---; env LC_ALL=C systemctl list-unit-files --type=service --state=enabled --no-legend --no-pager")
allowed=1 ;;
esac
if [[ $allowed -eq 0 ]]; then
if [[ "$cmd" =~ ^"${mark}"env\ LC_ALL=C\ df\ -P[ki]\ ${path}$ ]] \
|| [[ "$cmd" =~ ^"${mark}"env\ LC_ALL=C\ systemctl\ show\ --no-pager\ --property=LoadState,ActiveState,SubState\ --\ ${unit}$ ]]; then
allowed=1
fi
fi
if [[ $allowed -eq 1 ]]; then
exec /bin/sh -c "$cmd"
fi
echo "probeward-ssh-gate: command not allowed" >&2
exit 126Reload sshd. The gate was checked against the commands above and against a mount point and a unit name that try to chain a second command; it refuses those. A mount point with spaces or other unusual characters is refused too: widen the path pattern for it, knowing that you are widening what the account may ask for. Sensors added later may send other commands; if the gate refuses one, the sensor fails with command not allowed and the sensor's page says what it runs.
Even without the gate, the commands are read-only and the account has no rights, which is the layer that matters. The gate stops a stolen key from being used as a shell.
4. Host keys
The first successful connection of a sensor records the server's host key; a later poll that sees another key fails before any credential is sent. See ssh_disk. When you reinstall a host, forget the sensor's stored state.
5. Troubleshooting
| Symptom | Cause |
|---|---|
rejected the SSH credential | Wrong key or user, a key file with wrong permissions on the target (StrictModes), or AllowUsers without probeward. |
SSH host key changed | The host was reinstalled, or something is in the way of the connection. |
systemctl failed on the target | No systemd, or a container without D-Bus. |
| a process count that is too low | /proc is mounted with hidepid; see ssh_process. |