Erlang -- ssh_agent

# ssh_agent

###
Module

ssh_agent

###
Module Summary

Callback module for using an SSH agent instead of the default ssh_file callback.

###
Since

Module ssh_agent was introduced in OTP 23.0.

###
Description

This module defines a callback handler for the communication with an SSH Agent and can be used to replace the default callback. This allows to issue signing requests to an agent that stores SSH private keys to perform authentication.

Ssh_agent implements the ssh_client_key_api, to allow it to be used by setting the option key_cb when starting a client (with for example ssh:connect, ssh:shell ).

          {key_cb, {ssh_agent, []}}

The agent communication is 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.

In order to set a different socket path the socket_path option can be set.

          {key_cb, {ssh_agent, [{socket_path, SocketPath}]}}

Note

The functions are Callbacks for the SSH app. They are not intended to be called from the user's code!

###
Data Types

####
Options for the ssh_agent callback module

####
socket_path_option() = {socket_path, string()}

Sets the socket path for the communication with the agent.

####
timeout_option() = {timeout, integer()}

Sets the time-out in milliseconds when communicating with the agent via the socket. The default value is 1000.

####
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.

###
Exports

####
add_host_key(Host :: string(),
PublicKey :: public_key:public_key(),
Options) ->
ok | {error, Error :: term()}
OTP 23.0

####
add_host_key(Host,
Port :: inet:port_number(),
PublicKey :: public_key:public_key(),
Options) ->
Result
OTP 23.0

### Types

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.

####
is_host_key(Key :: public_key:public_key(),
Host :: string(),
Algorithm :: ssh:pubkey_alg(),
Options) ->
boolean()
OTP 23.0

####
is_host_key(Key :: public_key:public_key(),
Host,
Port :: inet:port_number(),
Algorithm :: ssh:pubkey_alg(),
Options) ->
boolean()
OTP 23.0

### Types

Host =
inet:ip_address() |
inet:hostname() |
[inet:ip_address() | inet:hostname()]
Options =
ssh_client_key_api:client_key_cb_options(call_ssh_file_option())

This callback is delegated to the ssh_file module.

####
user_key(Algorithm :: ssh:pubkey_alg(), Options) -> Result
OTP 23.0

### Types

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.