ssh_client_key_api(3)
π ssh_client_key_api β no wait, that's the whole NAME π
Okay bestie, gather round. This is the manual page for ssh_client_key_api, straight out of the Erlang Module Definition corner of the docs. It's a behavior module, and it's about to be your new obsession if you're into customizing how an SSH client handles public keys. β¨
β¨ NAME β¨
ssh_client_key_api β literally just -behaviour(ssh_client_key_api). That's it. That's the whole thing. Short king. π
π DESCRIPTION π
So this is a behavior that describes the API for public key handling of an SSH client. By implementing the callbacks defined in this behavior, you can customize the public key handling of an SSH client β yes, fully custom, main character energy, your rules.
By default the ssh application implements this behavior with help of the standard OpenSSH files, so if you never touch this, it just works. Check the ssh application manual for that default setup. π«Ά
πΈ DATA TYPES πΈ
client_key_cb_options(T)::
[{key_cb_private, [T]} | ssh:client_option()].
Okay so real talk. These are the options provided to ssh:connect/3,4. π«
The option list given in the key_cb option is available with the key key_cb_private. That's the lil secret backstage pass. π
π¦ CALLBACKS π¦
add_host_key(Host, PublicKey, Options)
Heads up bestie, this one is retired in favour for Module:add_host_key/4, which is the preferred API function. But listen β the calling SSH application will still try the add_host_key/3 if the call to add_host_key/4 failed. So it's not fully gone, it's just the backup dancer now. π
What it does: adds a host key to the set of trusted host keys. π
add_host_key(Host, Port, PublicKey, Options)
Adds a host key to the set of trusted host keys. Same job, glow-up edition. β¨
This function is preferred to the old Module:add_host_key/3 since it also uses the peer host port number and may return an error message. More info, more power. π₯
The OTP/SSH application first calls this function in the callback module, and then the old Module:add_host_key/3 for compatibility. Order matters, write that down. π
is_host_key(Key, Host, Algorithm, Options)
Retired in favour for Module:is_host_key/5, which is the preferred API function. The calling SSH application will still try the is_host_key/4 if the call to is_host_key/5 failed. Fallback queen. π
Checks if a host key is trusted. π
is_host_key(Key, Host, Port, Algorithm, Options)
Checks if a host key is trusted. That's the vibe check right there. β
This function is preferred to the old Module:is_host_key/4 since it also uses the peer host port number and may return an error message. Extra details = extra slay. π
The OTP/SSH application first calls this function in the callback module, and then the old Module:is_host_key/4 for compatibility. Again: first the new one, then the old one. Don't flip it. π
sign(PubKeyBlob, SigData, Options)
Sign the SigData with the private key corresponding to PubKeyBlob. That's it, that's the assignment. Signature moment, literally. βοΈπ
user_key(Algorithm, Options)
Fetches the users public key matching the Algorithm. Some key callback modules may return {ssh2_pubkey, PubKeyBlob :: binary()}. So check what you get back, iykyk. π§
NOTE: The private key contains the public key. Not me dropping lore at the end of the page π keep this in your brain forever.
And that's the whole page, bestie!! Every callback, every note, every retired function that's still hanging around for compatibility. You ate this. π
This masterpiece comes to you from Ericsson AB, courtesy of ssh 6.0.5, filed under ssh_client_key_api(3) β thanks for reading, mwah π
π¦ where this page comes from
- ubuntu stonking: erlang-doc 1:29.0.6+dfsg-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms