Add agent/deploy.sh: install and upgrade agents over SSH

Run from a workstation checkout; hosts need no git or Gitea access.
A plain run upgrades every host in agent/hosts (config and token kept);
--register runs `kernelwatch add-host --token-only` on the dashboard
over SSH and hands the token to the host on stdin, never argv or the
terminal; --rotate does the same with rotate-token. Newly registered
hosts are appended to agent/hosts. Failures are summarised and don't
stop the rest of the fleet.

Supporting changes: install.sh --token-file, and --token-only on
`kernelwatch add-host` / `rotate-token`. Tested end to end with ssh and
sudo stubbed to run locally against the real CLI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
patrickandClaude Opus 5.5 committed 2026-10-17 11:51:15 -04:00
1 parent a430a13fc8
commit 69d4cf6363
8 files changed
+456 -11

No files matched your search

+40 -1
View File
@@ -194,10 +194,49 @@ systemctl list-timers kernelwatch-agent.timer
journalctl -u kernelwatch-agent
```
### Deploying to many hosts
`agent/deploy.sh` does all of the above over SSH from your workstation's
checkout, so hosts need neither git nor Gitea access. Set it up once:
```sh
cp agent/deploy.conf.example agent/deploy.conf # SERVER_URL, DASHBOARD (ssh target)
cp agent/hosts.example agent/hosts # optional; --register fills it in
```
Then:
```sh
agent/deploy.sh --register web01 db01 # register on the dashboard + install
agent/deploy.sh # upgrade every host in agent/hosts
agent/deploy.sh web01 # upgrade one
agent/deploy.sh --rotate web01 # new token, reinstall
agent/deploy.sh --dry-run # show the plan
```
For each host it copies the agent into a private temp directory and runs
`install.sh`, which sends a first report, then deletes the temp directory.
With `--register`/`--rotate`, it also runs
`sudo kernelwatch add-host --token-only` on the dashboard host and passes the
token to the host on SSH stdin. The token never appears on a command line or
in your terminal. A plain run is an upgrade: config and token stay as they
are. You'll get sudo prompts on each host, and on the dashboard when
registering, unless you have passwordless sudo.
Both files are git-ignored. Host names default to each host's `hostname -s`;
put `<ssh target> <name>` in `agent/hosts` to override. For a host your
workstation can't reach directly (e.g. IPv6-only while you're on IPv4), give it
a jump host in `~/.ssh/config` and `deploy.sh` works unchanged:
```
Host zeus
ProxyJump eurus
```
## Server admin commands
```
sudo kernelwatch add-host NAME register a host, print its token
sudo kernelwatch add-host NAME register a host, print its token (--token-only for scripts)
sudo kernelwatch rotate-token NAME issue a new token (old one stops working)
sudo kernelwatch remove-host NAME delete a host and its history
sudo kernelwatch list-hosts hosts and when they last reported