ssh_agent(3)

πŸ“¦
version 29.0.6 Β· 3 versions
, in ubuntu stonking

✨ 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 the add_host_key and is_host_key callbacks are delegated to. Defaults to the ssh_file module. (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 is 1000. 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