# A monitoring SSH key that can only run one script

my status page logs into my NAS as root every 60 seconds, and that key can't do anything except run one report script.

the line in root's [`authorized_keys`](https://man.openbsd.org/sshd#AUTHORIZED_KEYS_FILE_FORMAT):

```
from="<laptop address>",restrict,command="/usr/local/sbin/sysdash-report" <public key>
```

- `command=` forces the script. whatever the client asks to run is ignored
- `restrict` turns off port forwarding, agent forwarding, X11 and the pty
- `from=` pins it to the laptop on the private cable, the only machine that can reach the NAS anyway

checked both ways: a requested command is ignored and the report comes back, and `-L` forwarding gets nothing.

the script prints facts only, as tab-separated lines: services, disk, memory, temperature, SMART counters, pending updates. the dashboard decides what's a problem, not the box. it carries a `REPORT_VERSION`, and the page warns while the NAS runs an older copy, because updating it is a manual step:

```bash
ssh nas 'install -m 0755 /dev/stdin /usr/local/sbin/sysdash-report' < hosts/report.sh
```

one thing to check on openmediavault: it manages SSH keys through its own salt states, so would the next apply wipe this line? no. its state only cleans `/var/lib/openmediavault/ssh/authorized_keys/`, and root's own file is left alone.

the first run found apt OOM-killed on the NAS, something that had been going on for nine days.

---

see also: [apt OOM-killed 75 times](/articles/apt-oom-no-dns), [a revoked key that still worked](/articles/ssh-revocation-test)
