module

Krikri::PluginHelpers::AuthorizedKeysFile

AuthorizedKeysFile - pure logic for ensuring a public key line is present/absent in an OpenSSH authorized_keys-style file, entirely without I/O so it's unit-testable with plain strings.

Constants

KEY_TYPES = ["ssh-rsa", "ssh-dss", "ssh-ed25519", "ecdsa-sha2-nistp256", "ecdsa-sha2-nistp384", "ecdsa-sha2-nistp521"] of ::String

Class methods

ensure(text : String, key_line : String, present : Bool) : Tuple(String, Bool)

Ensures key_line's signature is present (or absent) in text. Returns {new_text, changed}.

Source
ensure_keys(text : String, key_lines : Array(String), present : Bool, exclusive : Bool = false) : Tuple(String, Bool)

Multi-key form matching the real module's enforce_state: each key line is matched by its own signature; new keys are appended after existing ones in the order given. With exclusive (state present only), every existing key whose signature isn't among the new keys is deleted - real Ansible's "remove all other keys to honor exclusive".

Source
key_signature(line : String) : String | Nil

Extracts the "type base64blob" portion of a key line, ignoring any leading options and trailing comment - that's what makes a key unique, matching how sshd itself treats authorized_keys entries. Returns nil for blank/comment/unparseable lines.

Source