feat(hosts): manage servers and encrypted SSH credentials in UI (#7)
This commit is contained in:
+36
-2
@@ -28,7 +28,7 @@ programs inside run blocks (use the terminal panel for those).
|
||||
- **Workspace**: a git repo with the user's data, separate from the app code:
|
||||
`notebooks/*.md`, `hosts.yaml`, `CLAUDE.md` (format guide for Claude, shipped by ShellBook).
|
||||
- **Host**: an entry in `hosts.yaml` (`name`, `address`, `user`, `port`, optional `tags`).
|
||||
ShellBook connects with its own SSH key.
|
||||
Authentication is chosen per host in the Servers & SSH page (see ?4.1).
|
||||
- **Step**: a fenced block with a ShellBook attribute set. Kinds: `run`, `check`.
|
||||
- **Run record**: one execution of a step (host, rendered script, output, exit code,
|
||||
artifacts, timestamp). Appended to the audit log.
|
||||
@@ -127,12 +127,46 @@ only, then removed.
|
||||
## 4. Execution
|
||||
|
||||
- Scripts run as `bash -euo pipefail -s` with the script on stdin; no TTY.
|
||||
- SSH via `ssh2`, ShellBook's own key, **strict host key checking**. Unknown host key →
|
||||
- SSH via `ssh2`, per-host authentication, **strict host key checking**. Unknown host key →
|
||||
UI shows the fingerprint and asks once (TOFU), then stored in the workspace's `known_hosts`.
|
||||
- Output is streamed to the browser over WebSocket (stdout/stderr interleaved, with exit code).
|
||||
- Every run is appended to `data/audit.jsonl`: time, notebook, step id, host, rendered script, exit code, duration. Secrets never appear.
|
||||
- One step per host at a time (queue); different hosts in parallel.
|
||||
|
||||
### 4.1 Hosts and SSH credentials
|
||||
|
||||
The Servers & SSH page manages host name, address, user, port and tags without YAML
|
||||
editing. Changes preserve YAML comments/order where practical and use an opaque
|
||||
inventory version; stale writes return 409. Host renames migrate stored credentials;
|
||||
notebook host references remain literal and must be updated by the user. The file
|
||||
watcher publishes `file.changed` / `file.deleted` with path `hosts.yaml`.
|
||||
|
||||
Per-host authentication is ShellBook key (default), password (including non-echoed
|
||||
keyboard-interactive password prompts), or private key with optional passphrase.
|
||||
Paste or upload the key from the browser. ssh2 1.17.0 does not expose client user
|
||||
certificate pairing; the UI explicitly disables OpenSSH certificates. All remote
|
||||
execution, checks, uploads and artifact downloads use the same authenticated client.
|
||||
Strict host key checks and explicit TOFU acceptance remain mandatory.
|
||||
|
||||
Passwords, private keys and passphrases are stored only in the data directory,
|
||||
AES-256-GCM encrypted with random 96-bit nonces and host-name AAD. A random 256-bit
|
||||
key file and credential files have POSIX mode 0600; ciphertext updates use atomic
|
||||
rename. Keep dataDir outside the workspace repository. APIs never return stored
|
||||
secrets: only type, key fingerprint (when applicable), and set-at time. Selecting
|
||||
the default or deleting a host deletes its credential. Credential values join the
|
||||
existing streaming/audit redaction list; host actions discard remote output and
|
||||
return only an exit status or a TOFU fingerprint challenge.
|
||||
|
||||
The page shows the ShellBook public key with Copy, Test connection (`true`),
|
||||
Install ShellBook key, and Forget host key. Installation requires the stored
|
||||
password and previews the literal script; the server rejects a mismatched preview
|
||||
before connecting. It appends the public key idempotently to the remote user's
|
||||
`~/.ssh/authorized_keys`, with all quoting through core `shellQuote`. The password
|
||||
remains selected until the user chooses ShellBook key after successful installation.
|
||||
Forgetting a host key requires UI confirmation and removes only that endpoint,
|
||||
preserving other aliases. All management routes use the existing session and origin
|
||||
checks and responses disable caching.
|
||||
|
||||
## 5. UI
|
||||
|
||||
- **Notebook list** (left), **notebook view** (center), **AI/terminal panel** (right, collapsible).
|
||||
|
||||
Reference in New Issue
Block a user