Skip to main content

Crate authkeys_managed

Crate authkeys_managed 

Source

Functions§

authorized_keys_path
Path to the ACCEPTOR daemon user’s authorized_keys ($HOME/.ssh/authorized_keys). Deliberately rooted at $HOME (NOT the config dir), that is where sshd reads it. Tests sandbox the write by running the acceptor with HOME set to a temp.
bootstrap_cache_clear
Drop the cached bootstrap for device (forces a full bootstrap next time).
bootstrap_cache_get
The cached login for device if its bootstrap is still fresh, else None (None = do a full bootstrap). Outer Some = fresh cache hit; the inner Option is the login account the acceptor last reported (None when it reported none).
bootstrap_cache_put
Record a successful bootstrap so the next filament ssh to device skips it.
ensure_managed_key
Ensure the managed ed25519 keypair exists; generate it on demand via ssh-keygen if absent. Returns the PUBLIC key line (one line, no trailing newline). The private key NEVER leaves disk and is never printed.
has_block
True if a marked block for device is present (used by the gate to prove the block is installed / removed).
host_pinned
True if dest_token already has a pinned host key in our known_hosts (the bootstrap already ran for it at least once).
host_pubkeys
Read the acceptor’s real public host keys. Prod reads /etc/ssh/ssh_host_*.pub; the gate points FILAMENT_SSH_HOSTKEY at a throwaway sshd’s hostkey pubfile so it never needs to touch the system’s. Returns the raw pubkey lines (e.g. “ssh-ed25519 AAAA…”).
install_authorized_key
Install (or replace) pubkey in a marked block for device in authorized_keys. Idempotent: a re-grant replaces that device’s block rather than appending a duplicate. Creates ~/.ssh (0700) and the file (0600) if absent. SECURITY: the caller MUST have verified the trusted channel + shell cap before calling this. The pubkey is re-validated here (M-3), defense in depth, so a bad key is NEVER written even if a caller forgot to check.
known_hosts_path
Filament-private known_hosts (pin store), never the user’s.
managed_key_path
Managed private key path (id_ed25519). The pubkey is <this>.pub.
pin_host_keys
Pin the acceptor’s host keys into our private known_hosts, keyed by the EXACT destination token ssh will use (so the pin is not silently inert). Replaces any prior pins for that token (host keys can rotate). Each hostkeys entry is a pubkey line like “ssh-ed25519 AAAA…”.
remove_authorized_key
Remove device’s marked block from authorized_keys (the “removable” half of the audit story; used by filament revoke). No-op if absent.
strip_block
Return content with the # BEGIN/END filament-managed <device> block (and the lines between) removed. Lines outside any such block are preserved verbatim. Path-pure (testable), the file I/O wrappers call this.
validate_pubkey
M-3 (authorized_keys injection): validate that pubkey is a SINGLE, well- formed ssh public-key line before it is ever written. A trusted+shell peer could otherwise send a pubkey containing an interior \n (which .trim() does NOT strip) to inject EXTRA authorized_keys lines, extra keys, a command=/from= forced-command, etc. We reject anything with a control character (newline, CR, tab, …) or more than one whitespace-separated key line, and require the shape <key-type> <base64-blob> [single-line comment].