ssh_agent(3)
β¨ ssh_agent β the callback module that lets your Erlang app borrow an SSH agent π
okay bestie, quick vibe check: this is ssh_agent from the Erlang docs (module definition energy π¦). It's a whole callback module, and it's lowkey iconic. Let's get into it.
πΈ NAME πΈ
ssh_agent β a callback module for using an SSH agent instead of the default ssh_file callback. periodt.
π DESCRIPTION π
So this module defines a callback handler for talking to an SSH Agent, and you can use it to replace the default callback. Which is huge, because it means you get to slide your signing requests over to an agent that's holding your SSH private keys and just let it do the authentication. no cap. π«Ά
Ssh_agent implements ssh_client_key_api, so you can use it by setting the option key_cb when you start a client (with, for example, ssh:connect, ssh:shell). it's giving plug-and-play:
{key_cb, {ssh_agent, []}}
The agent communication gets established through a UNIX domain socket. By default, the socket path will be fetched from the SSH_AUTH_SOCK environment variable, which is the default socket path in the agent implementation of OpenSSH. (yes bestie, the classic β¨)
And if you wanna set a different socket path, there's the socket_path option for exactly that:
{key_cb, {ssh_agent, [{socket_path, SocketPath}]}}
NOTE: The functions are Callbacks for the SSH application. They are not intended to be called from the user's code! π like, do not. please. they're not for you, they're for the SSH app. the way that I need you to understand this π
π DATA TYPES π
call_ssh_file_option() :: {call_ssh_file, atom()}β the module which theadd_host_keyandis_host_keycallbacks are delegated to. Defaults to thessh_filemodule. (yes it just hands those two off, iconic delegation behavior π)socket_path_option() :: {socket_path, string()}β sets the socket path for the communication with the agent. your lil custom door to the agent πͺβ¨timeout_option() :: {timeout, timeout()}β sets the time-out in milliseconds when communicating with the agent via the socket. The default value is1000. so a solid one second, fr fr β³
π₯ FUNCTIONS π₯
π add_host_key
add_host_key(Host, inet:port_number(), public_key:public_key(), Options) ->
Result
when
Host :: inet:ip_address() | inet:hostname() | [inet:ip_address() | inet:hostname()],
Options :: ssh_client_key_api:client_key_cb_options(call_ssh_file_option()),
Result :: ok | {error, Error :: term()}.
This callback is delegated to the ssh_file module. that's the whole thing, she's a delegator π
π¦ is_host_key
is_host_key(public_key:public_key(), Host, inet:port_number(), ssh:pubkey_alg(), Options) ->
boolean()
when
Host :: inet:ip_address() | inet:hostname() | [inet:ip_address() | inet:hostname()],
Options :: ssh_client_key_api:client_key_cb_options(call_ssh_file_option()).
Also delegated to the ssh_file module. same energy, same module, we love consistency π
β user_key
user_key(Algorithm :: ssh:pubkey_alg(), Options) -> Result
when
Result :: {ok, public_key:private_key()} |
{ok, {ssh2_pubkey, PubKeyBlob :: binary()}} |
{error, string()},
Options :: ssh_client_key_api:client_key_cb_options(socket_path_option() | timeout_option()).
Types and description
See the api description in ssh_client_key_api, Module:user_key/2. go read that one too bestie, it's the main character's lore π
and that's the whole page!! π no SEE ALSO section in this one, so nothing to chase down β you already ate everything on the menu. π
okay mwah, hope this helped, you're gonna slay your SSH agent setup!! π§π
β with love, Ericsson AB, ssh 6.0.5, and yes this is ssh_agent(3), bye bestie!! β¨π
π¦ 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