OpenBSD shells VM provisioning (reproducible config + Go tooling)
Find a file
James Trotter f6c69f29fd
Some checks failed
CI / test (pull_request) Successful in 5m6s
CI / release (push) Successful in 2m30s
CI / release (pull_request) Failing after 0s
CI / test (push) Successful in 4m53s
feat(abuse): fingerprint personal values typed in shell history
One person running several shells can change emails, IPs, keys and proxy
configs, but tends to type the same things everywhere: their own
server's IP, a personal domain, an email, a bot or API token. The
fingerprint scan now reads each home's bash/zsh/fish (and python/mysql)
history and reports those values as history_token fingerprints. Like
proxy secrets, they are salted and hashed, and Detail only says what
kind of value it is.

Noise is filtered out first: private/CGNAT addresses, the host's own
networks, our hosts, public resolvers, well-known domains (code hosts,
registries, big services, common Reality cover sites, our own), names
containing the account's own username, pure-hex checksums, paths, and
TLDs that double as field names (so "{{.HostConfig.RestartPolicy.Name}}"
isn't a domain). On the live host's 29 shells this finds no shared
values, as expected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 14:22:52 -05:00
.forgejo ci: publish with the automatic token when REGISTRY_TOKEN isn't set 2026-10-17 13:04:37 -04:00
cmd feat(abuse): proxy clients per user, router and address from Traefik's log 2026-11-29 13:17:11 -05:00
dev/local-incus fix(shells): raise the process cap to 4096 (#12) 2026-11-07 00:40:01 +00:00
docs scaffold: repo skeleton + README 2026-06-18 01:40:17 -04:00
host fix(ids): suppress truncated-packet decoder alerts on incusbr0 2026-11-30 11:27:57 -05:00
images feat(shells): latest Go/PHP + nginx, in-place upgrades, 512MB+shared limits 2026-06-19 22:09:19 -04:00
internal feat(ids): rollup of a range's alerts per shell, direction and rule 2026-11-29 22:51:45 -05:00
pkg/shells feat(abuse): fingerprint personal values typed in shell history 2026-11-30 14:22:52 -05:00
.gitignore feat: per-container metrics via Telegraf + host vmagent 2026-06-19 11:02:10 -04:00
go.mod fix(shells-enter): terminal only when the session has one 2026-10-17 17:27:12 -04:00
go.sum feat(shellsd): key info, restart, and browser console for the portal 2026-10-17 12:30:52 -04:00
README.md fix(host): turn NIC offloads off on Suricata's capture interfaces 2026-11-29 22:40:02 -05:00

shells-config

Public free-shell program for IRCNow / sh.ircforever.org.

Each user picks a name and gets <name>.sh.ircforever.org, an Incus container on the shells VPS (89.167.23.102, Hetzner Helsinki), and a dedicated IPv6 /128 from 2a01:4f9:c014:663f::/64 routed directly into their container.

Architecture

main VPS (control plane)  ──HMAC POST──▶  shellsd on shells VPS
                                              │
                                              ▼
                                       incus exec / useradd /
                                       Traefik fragment write /
                                       DNS provider call
  • pkg/shells/ — library. Backend interface + Incus implementation. IPv6 allocator, JSON state, Traefik file fragments, Cloudflare DNS client.
  • cmd/shellsd/ — webhook receiver daemon. systemd unit; listens on 127.0.0.1:8090, fronted by Traefik on api.sh.ircforever.org.
  • cmd/shellctl/ — break-glass CLI for the shells host.
  • internal/webhook/ — HMAC verify + HTTP handlers.
  • host/ — config that lives on the shells VPS:
    • bootstrap.sh — idempotent host bootstrap (incus + UFW + sysctl + sshd)
    • incus-init.yaml — preseed for incus admin init
    • sshd-shells.conf — Match Group shells block for sshd
    • shells-enter + shells-enter-root — login-shell wrapper into the user's container (via sudo + the sudoers rule below)
    • sudoers-shells — %shells ALL=(root) NOPASSWD: …shells-enter-root
    • shellsd.service — systemd unit
    • telegraf.conf — baked into the base image; exposes in-guest metrics on :9273
    • observability/ — host-side vmagent (scrapes each container's telegraf and remote-writes to the central VictoriaMetrics) + shells-targets.{py,service,timer} that regenerate the scrape list from incus list
  • images/build-shells-base.sh — bake the Ubuntu 24.04 base image (incl. Telegraf)

Webhook API

All requests POST JSON to https://api.sh.ircforever.org/v1/… signed with X-Signature: sha256=<hex(hmac_sha256(secret, body))> + X-Timestamp (5-minute skew window).

Endpoint Body Effect
POST /v1/provision {username, pubkey} create container, host account, Traefik fragment, DNS records
POST /v1/deprovision {username} reverse
POST /v1/evidence {username, snapshot} read-only staff report before a ban: SSH logins (host jump + in-shell), portal activity, processes, sockets, cron/autostart, shell histories, recent files, executables with sha256, keys, podman, sites; snapshot also snapshots the container and home volume (evidence-<UTC time>)
POST /v1/shell-details {username} managebot's "Shell details" panel, read-only: Incus state, created/started times, uptime, limits (CPU, memory, processes, disk) and current use; private IPv4 on incusbr0 (a warning when there is none: the Traefik sites are down), routed IPv6 and MACs; every Traefik route (<user>.yml, webhost-<user>-<label>.yml) with its backend and a TCP connect check from the host (stale when it isn't the shell's IPv4); TCP/UDP listeners (ss) with processes, public when reachable over IPv6; the process list (base marks the image's services and Podman plumbing); each account's Podman containers; every crontab. Incus 8 s, in-shell script 15 s (incus exec -n, so stdin is never read), 25 s overall; a part that fails is listed in errors and the rest still comes back, so a stopped shell still shows its config and routes. 404 for no such shell
POST /v1/abuse – latest abuse scan: per-shell findings (disguised or known-bad processes, cron restarters, outbound IRC reconnect storms / SSH fan-out / port scans / direct SMTP, YARA file signatures, IDS alerts) and proxy clients for managebot to show as flags
POST /v1/abuse-scan – runs an abuse scan now (starts shells-abuse-scan.service, waiting for one already running) and returns its report, as /v1/abuse does
POST /v1/ids-events {user?, type? (alert|ssh|tls|all), sid?, q?, since?, until?, before?, limit?} IDS event browser for managebot: Suricata's eve.json and its rotations (eve.json.1, eve.json.N.gz) read newest-first, each record tied to the shell on either end (direction out when the shell opened the connection), with alert rule, SSH client/server versions or TLS server name, version and JA3/JA4; q matches signature, SSH software, TLS name or an address; limit 200 (max 1000); page with before = the previous next. Also a summary (counts by type, top rules, top shells; the whole range when since is given). At most 200 MB and 10 s per request (truncated when cut short)
POST /v1/block {username} stop the container (login refused, data kept)
POST /v1/unblock {username} start a blocked container
GET /v1/list – list provisioned shells
GET /healthz – 200 if incus reachable
GET /metrics – Prometheus exposition

Abuse scan

shells-abuse-scan.timer runs shellsd abuse-scan every 15 minutes (pkg/shells/abuse*.go). It only reads and flags; staff decide in managebot.

  • Processes and crontabs in each running shell: known miners, proxies, tunnels and attack tools by name; processes disguised as system ones (crond, [kworker/…]); binaries running from /tmp or a hidden home directory, or deleted while running; a core pegged for the whole window; cron entries that restart something from a hidden or temp directory.
  • Outbound connections: the scan installs table inet shellwatch (count only, never drops) which counts new flows per shell → destination:port, and reads-and-resets it each run. Flags reconnect storms to one IRC server (nick-grabbers), many IRC servers, SSH to many hosts, port scans, wide fan-out, direct SMTP attempts and stratum pool ports.
  • Files: YARA (apt install yara) with pkg/shells/abuse.yar over the home volumes and the shells' /tmp + /var/tmp, hourly, only files changed since the last pass (weekly, or when the rules change, everything).
  • IDS alerts: Suricata on the host (host/suricata/, alerts only, never blocks) watches the shells' traffic: IPv4 on incusbr0 before NAT, IPv6 on eth0 for the shells' /64, with the Emerging Threats Open rules (updated daily by suricata-update.timer). Each scan reads the alerts added to /var/log/suricata/eve.json since the last one and keeps them per shell and rule for a day (kind ids_alert). Only connections the shell opened count, and rules about ordinary traffic (SURICATA, ET INFO, ET POLICY, ET HUNTING, …) are left out. Suricata also logs SSH client versions and TLS server names to eve.json; managebot's /ids page browses all of it through POST /v1/ids-events. Addresses map to the shells that have them now, so an old record for a since-reused IPv4 can name the wrong shell. suricata-nic-offload.service turns TSO/GSO/GRO (and eth0's hardware GRO) off on both capture interfaces at boot: with them on, Suricata gets merged oversized packets it can't inspect and logs ~20k "truncated packet" alerts a day. Old alerts are archived under /var/log/suricata/archive/, which shellsd doesn't read. Suricata only reopens eve.json on a restart (SIGHUP and reopen-log-files didn't), so restart it after moving the file.
  • Proxy clients: Traefik's access log (the traefik container's Docker json log, found with docker inspect traefik; SHELLSD_TRAEFIK_LOG overrides it, off turns it off) is read on from where the last scan stopped. Requests to a user's site (<user>@file, or <user>-h-<label>@file for an extra address) that became a long-lived websocket (status 0 or 101, or a 499 held for at least 5s; quick 499s are scanners) are counted per user, router and client address, with first/last seen and paths, and kept for 90 days after the client was last seen, also for users removed since. The host's and the shells' own addresses are left out. They go in the report as proxy_clients, not findings: managebot matches a client across accounts (one person running VLESS proxies on several shells uses them from the same address) and flags the overlap.

State and the report live in /var/lib/shells/abuse/ (SHELLSD_ABUSE_DIR).

Metrics

Each container runs Telegraf (baked into shells-base) exposing in-guest metrics (cpu/mem/disk/net/netstat/system/…) on :9273 — no credentials live inside the container (users control their own shell), so it only exposes metrics; nothing pushes with a secret from inside. Telegraf is un-killable by the user because shells are unprivileged (no sudo). A host-side vmagent (host/observability/) scrapes every container over the incus bridge and remote-writes to the central VictoriaMetrics on the main VPS; shells-targets.timer keeps the scrape list in sync with incus list. Grafana renders the per-shell Proxmox LXC Container Data community dashboard (ID 23742), retargeted to these metrics.

container telegraf :9273  ──scrape──▶  vmagent (host)  ──remote_write──▶  VictoriaMetrics (VPS)  ──▶  Grafana

Per-user surface

Path What lands there
ssh <user>@89.167.23.102 (IPv4) host sshd → shells-enter → incus exec shells-<user>
ssh <user>@<user>.sh.ircforever.org (IPv6) direct to container's own sshd (when DNS AAAA is set)
https://<user>.sh.ircforever.org Traefik (host) → container's :80

Bootstrap a fresh shells host

# On the host, as root:
git clone … /usr/local/share/shells-config
cd /usr/local/share/shells-config
sudo host/bootstrap.sh
sudo images/build-shells-base.sh

# Install the daemon binary + secret:
sudo install -m 755 shellsd /usr/local/bin/shellsd
SECRET=$(openssl rand -hex 32)
sudo sed -i "s|^SHELLSD_HMAC_SECRET=.*|SHELLSD_HMAC_SECRET=$SECRET|" /etc/shellsd/env
sudo systemctl enable --now shellsd

Plan

See the parent plan file at /Users/james/.claude/plans/polymorphic-gliding-rossum.md.

Auto-deploy (shellsd + portal)

CI (.forgejo/workflows/ci.yml) tests every push; on main it publishes shellsd to the Forgejo generic package registry (/api/packages/ircforever/generic/shellsd/{<commit>,latest}). The portal repo (shells-dashboard) publishes shells-dashboard the same way.

On the shells box, shells-autodeploy.timer checks every 5 minutes and installs a newer build: sha256-verified, previous binary kept as <bin>.bak.autodeploy, service restarted and health-checked (shellsd /healthz; the portal must serve / and still answer /api/shell with 401). A failed check rolls back and that version is skipped. shellsd isn't restarted while it has child processes (a rebuild/upgrade or an open web console); it retries on the next run.

One-time install (root):

install -m 755 host/shells-autodeploy.sh /usr/local/sbin/shells-autodeploy
install -m 644 host/shells-autodeploy.service host/shells-autodeploy.timer /etc/systemd/system/
systemctl daemon-reload && systemctl enable --now shells-autodeploy.timer
journalctl -u shells-autodeploy -f   # watch it

CI needs a REGISTRY_TOKEN secret (a Forgejo token with package write) on both repos or the org. Tested by host/test/autodeploy_test.sh.