Rewrite the host-access runbook for the installed model: ubuntu may sudo into the bot accounts and run the docs/backup allowlist but has no root; operator holds NOPASSWD:ALL via its own SSH key; root SSH stays closed. Record the closed backup root path, the silent watchdog, verification commands, safe-mode recovery, and rollback. Update the fleet and backup pages to match.
146 lines
6.2 KiB
Markdown
146 lines
6.2 KiB
Markdown
# Agent host access
|
|
|
|
The agent host (`ov-0f018e`, an Infomaniak VPS Lite instance) separates three
|
|
levels of privilege: the bots, the steward, and the human operator.
|
|
|
|
## The model
|
|
|
|
| Account | Role | Privilege |
|
|
|---|---|---|
|
|
| `socialbot`, `infrabot`, `designbot`, future working-group bots | agents | own Unix user, own gateway unit, **no sudo at all** |
|
|
| `ubuntu` | steward agent (Inferencebot) | may act inside the bot accounts and run the docs/backup service commands; **no root** |
|
|
| `operator` | human operator | own SSH key, full `sudo` (`NOPASSWD:ALL`); root SSH login stays closed |
|
|
|
|
The steward is the fleet administrator, not a root user. Root belongs to a
|
|
person: the operator signs in as `operator` with an SSH key and escalates
|
|
deliberately with `sudo -i`.
|
|
|
|
### sudoers files
|
|
|
|
- `/etc/sudoers.d/91-bot-access`
|
|
`ubuntu ALL=(socialbot,infrabot,designbot) NOPASSWD: ALL`
|
|
- `/etc/sudoers.d/90-inferencebot-restricted`
|
|
`ubuntu` may only start/stop/restart `docs-deploy-poll.service` and
|
|
`agent-backup.service`/`.timer`, and read `docs-deploy-poll` logs.
|
|
- `/etc/sudoers.d/90-operator`
|
|
`operator ALL=(ALL) NOPASSWD:ALL`
|
|
- `/etc/sudoers.d/90-<bot>-nosudo`
|
|
`<bot> ALL=(ALL) !ALL` — each bot is denied sudo, including via its own
|
|
account.
|
|
|
|
Do not re-add the old cloud-init `ubuntu ALL=(ALL) NOPASSWD:ALL` rule. The
|
|
steward must not regain root, and the operator account is the root door.
|
|
|
|
### No passwords
|
|
|
|
- `ubuntu` and the bot accounts are password-locked (cloud image
|
|
`lock_passwd: True`); SSH password authentication is disabled
|
|
(`/etc/ssh/sshd_config.d/60-cloudimg-settings.conf`).
|
|
- Access is SSH public keys only. Do not set a password on `ubuntu`, a bot, or
|
|
`operator` as a convenience.
|
|
- `operator`'s key is copied from `/home/ubuntu/.ssh/authorized_keys` when the
|
|
account is created. If the operator's key rotates, update **both**
|
|
`/home/ubuntu/.ssh/authorized_keys` and
|
|
`/home/operator/.ssh/authorized_keys`.
|
|
- Root SSH login is not authorized; do not add root authorized keys.
|
|
|
|
## Root-owned execution paths
|
|
|
|
- **Docs publisher.** `/usr/local/sbin/docs-poll` and `/usr/local/sbin/docs-publish`
|
|
are root-owned; the build runs as `docsbuild` with a scrubbed environment.
|
|
- **Nightly backup.** `agent-backup.service` runs as root with
|
|
`ExecStart=/usr/local/sbin/agent-backup`, a root-owned copy of
|
|
`~/.hermes/scripts/backup.sh`. The source script stays editable by `ubuntu`,
|
|
but the unit executes the installed root-owned copy.
|
|
`/usr/local/bin/restic` is `root:root`.
|
|
- **Backup credentials.** `RESTIC_PASSWORD`, `RESTIC_REPOSITORY`,
|
|
`SWB_S3_ACCESS_KEY`, `SWB_S3_SECRET_KEY` live only in root-only
|
|
`/etc/agent-backup.env` (0600). The root script must not source
|
|
`/home/ubuntu/.hermes/.env` and must not put `/home/ubuntu/.local/bin` on its
|
|
`PATH`; either would make an agent-writable file a root code-execution path.
|
|
- **Watchdog.** `check_root_trust.py` (daily cron) stays silent when healthy and
|
|
alerts if broad sudo returns, `sudo -n true` succeeds, a root-executed binary
|
|
is agent-owned, or a root script trusts agent files. It is silent as of
|
|
2026-11-21.
|
|
|
|
Any new root-executed script that reads an agent-writable file is a root path.
|
|
Audit it before installing it as root code.
|
|
|
|
## Verification
|
|
|
|
Run from an operator session:
|
|
|
|
```bash
|
|
# steward: bot access, no root
|
|
sudo -iu socialbot id # uid=1002
|
|
sudo -iu infrabot id # uid=1001
|
|
sudo -iu designbot id # uid=1003
|
|
sudo -n true # must fail: interactive authentication required
|
|
sudo -n /usr/bin/id # must fail
|
|
|
|
# operator: root door
|
|
sudo -n true && echo root-ok # root-ok
|
|
sudo -i
|
|
|
|
# root-trust watchdog: silence is the pass
|
|
python3 ~/.hermes/scripts/check_root_trust.py
|
|
```
|
|
|
|
## Recovery when root is unreachable
|
|
|
|
If sudo policy or the operator key is wrong, or no in-band root remains, use the
|
|
provider's rescue environment. On Infomaniak VPS Lite it is called **Safe mode**,
|
|
not "Rescue".
|
|
|
|
1. Manager → **VPS** → the server → **MANAGE** → **Restart the server (Safe
|
|
mode)**. Services stop while it is booted.
|
|
2. Connect to the rescue image as user `infomaniak` (temporary rescue password
|
|
from the panel if SSH asks). The rescue image has a different host key, so
|
|
use `-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no` for this
|
|
session only. Then `sudo -i`; confirm `id -u` is `0`.
|
|
3. Identify the disks with `lsblk -f`. The rescue system is the first disk
|
|
(root partition hostname `ik-rescue`). The cloud disk is the second disk; its
|
|
root partition is labelled `cloudimg-rootfs`, usually `/dev/sdb1`. Mount it:
|
|
|
|
```bash
|
|
mount /dev/sdb1 /mnt
|
|
cat /mnt/etc/hostname # must print ov-0f018e
|
|
```
|
|
|
|
If it prints `ik-rescue` or the file is missing, unmount and mount the
|
|
`cloudimg-rootfs` partition instead.
|
|
4. Run the staged recovery script, kept on the cloud disk:
|
|
|
|
```bash
|
|
less /mnt/home/ubuntu/recover.sh # inspect first
|
|
bash /mnt/home/ubuntu/recover.sh
|
|
```
|
|
|
|
It backs up the current sudoers files to
|
|
`/mnt/root/pre-recovery-YYYYMMDD/`, writes the bot-access and operator rules,
|
|
ensures the operator user and key, closes the backup root path, and runs
|
|
`visudo -c`. Do not unmount `/mnt` while it runs.
|
|
5. `umount /mnt`, then **MANAGE → Restart the server (Classic mode)**.
|
|
6. Verify with the commands above. The normal SSH host key returns after the
|
|
classic boot.
|
|
|
|
A narrative handoff of the same procedure, with no credentials, is kept at
|
|
`/home/ubuntu/recovery-context.txt` on the host.
|
|
|
|
### Rollback
|
|
|
|
- Previous sudoers files: `/root/pre-recovery-YYYYMMDD/` on the cloud disk.
|
|
- Original cloud-init sudoers: `/root/sudoers-cloud-init.bak` (0600).
|
|
- Provider snapshots are the outer rollback.
|
|
- Restoring the broad cloud-init rule is **not** the intended end state; it is
|
|
only a temporary recovery step while a narrower rule is installed.
|
|
|
|
## Things not to do
|
|
|
|
- Do not restore `ubuntu ALL=(ALL) NOPASSWD:ALL`.
|
|
- Do not set a password on any account; keep access key-based.
|
|
- Do not use the backup unit's agent-owned binary, `PATH`, or `.env` as a
|
|
shortcut to root; that is the hole, not a recovery channel.
|
|
- Do not run a root-owned unit against agent-writable files without a root-trust
|
|
review.
|