Skip to main content

Module ssh

Module ssh 

Source
Expand description

SSH to a server’s own system (a Proxmox VE node, say): with a key the caller keeps at a path it chooses (ensure_key), the server’s host keys trusted on first use (known_hosts) and checked strictly from then on. Every ssh, ssh-keygen and ssh-keyscan runs through the context’s ProcessRunner.

Which keys a user is shown and how they confirm them is the caller’s: known_hosts::offered reads what a server offers, known_hosts::confirm writes the ones confirmed.

Modules§

known_hosts
A server’s SSH host keys, trusted on first use: the keys it offers are read (ssh-keyscan) and given to the caller with their SHA-256 fingerprints, as ssh-keygen -lf and the server’s own console show them; once the caller confirms them (a user who compared them, say), they are written to a known_hosts file the caller names, and every Target checks them strictly. A server offering other keys is refused until the new ones are confirmed.

Structs§

Password
A password ssh is answered with, through its askpass hook: a script written into askpass_dir (the caller’s own folder, never a shared temporary one) that prints the password ssh is given in its environment. Never shown by Debug.
Target
Where to SSH, and as whom.

Enums§

SshError
Why an SSH step failed.

Functions§

batch_options
The -o values of an SSH that runs unattended: only the host keys in known_hosts are accepted (a host with none or another is refused, never pinned silently), no prompt, a short connect timeout, and keepalives, so a server that stops answering mid-command ends it in under a minute.
config_path
A path as the value of an ssh -o Key=value option. OpenSSH splits option values into words (on whitespace, honouring quotes and backslash escapes) and expands % tokens in file paths: unescaped, a path with a space (~/Library/Application Support/…) became two files. Escaped here so ssh reads the path back verbatim (a tab can’t be escaped this way).
ensure_key
The key at path, made when there is none (ssh-keygen -t ed25519, no passphrase, comment as its comment), and its public half, one line. A key already there is kept as it is: servers that trust it keep working.
public_half
Where the public half of the key at path is (<path>.pub).
sh_quote
s single-quoted for a POSIX shell (the remote command’s).