Expand description
Push a public key onto a remote host’s ~/.ssh/authorized_keys.
Equivalent of ssh-copy-id without the dependency: spawns a single
ssh invocation per host, pipes the public key over stdin, and runs an
idempotent shell snippet on the remote that creates ~/.ssh if
missing and appends the key only when it is not already present.
The remote snippet never sees the pubkey via the shell command line (which would require fragile escaping). Stdin is the canonical channel for binary-ish content over SSH.
Structs§
- KeyPush
Result - One row in the in-flight push result list. Populated as worker
threads complete and surfaced to the UI via
AppEvent::KeyPushResult.
Enums§
- KeyPush
Outcome - Outcome for one host in a push run. The renderer summarises these
into a toast (when every entry is
Appended/AlreadyPresent) or a sticky error block (when at least one isFailed). - Pubkey
Validation Error - Validation outcome for a public-key file’s contents.
Constants§
- PUBKEY_
MAX_ BYTES - Maximum size of a
.pubfile we will accept. OpenSSH’s RSA-8192 keys serialise to ~3 KiB; we cap at 16 KiB to leave headroom for comments and reject pathological inputs (symlinks to logs, /dev/urandom).
Functions§
- classify_
stdout - Parse the remote snippet’s stdout into an outcome. Pure helper so the worker and tests share the same classification. Match is against the last non-empty line (stripped of trailing CR) so motd or login-banner output before the marker is tolerated.
- pubkey_
path_ for - Resolve the local public-key path for a key whose
display_pathis~/.ssh/id_ed25519. Expands the tilde and appends.pub. The caller is expected to validate the file exists before reading. - push_
to_ host - Push
pubkeyto the remotealiasover SSH. Synchronous: spawnsssh -F <config_path> -T -o ConnectTimeout=10 -- <alias> <REMOTE_SNIPPET>, pipespubkeyto stdin, waits for the child to finish, and returns the parsed outcome. The cancel flag is observed before the spawn so a rapid Esc after launching the batch can short-circuit pending hosts. - read_
pubkey_ file - Read a
.pubfile with a hard byte cap and reject anything that is not a regular file. On Unix the open usesO_NOFOLLOWso a symlink at the .pub path errors out instead of silently dereferencing into a log file or/dev/urandom. - validate_
pubkey - Parse and validate a
.pubfile’s contents into a single canonicalauthorized_keysline. Rejects multi-line input (which would silently install several keys, including embeddedcommand=clauses), unknown algorithms, and unparseable base64 bodies. The returned string is trimmed of trailing whitespace / CR so the remotegrep -qxFdedup step matches byte-for-byte across pushes.