Erlang -- ssh_agent

SSH

Reference Manual

Version 4.12

- User's Guide
- Reference Manual
- Release Notes
- PDF
- Top

- Expand All
- Contract All

### Table of Contents

- SSH (App)
- ssh
  - Top of manual page
  - close/1
  - connect/3
  - connect/4
  - connect/2
  - connect/3
  - connection_info/1
  - connection_info/2
  - daemon/1
  - daemon/2
  - daemon/3
  - daemon_info/1
  - daemon_info/2
  - default_algorithms/0
  - get_sock_opts/2
  - hostkey_fingerprint/1
  - hostkey_fingerprint/2
  - hostkey_fingerprint/2
  - set_sock_opts/2
  - shell/1
  - shell/2
  - shell/3
  - start/0
  - start/1
  - stop/0
  - stop_daemon/1
  - stop_daemon/2
  - stop_daemon/3
  - stop_listener/1
  - stop_listener/2
  - stop_listener/3
  - tcpip_tunnel_from_server/5
  - tcpip_tunnel_from_server/6
  - tcpip_tunnel_to_server/5
  - tcpip_tunnel_to_server/6
- ssh_client_channel
  - Top of manual page
  - call/2
  - call/3
  - cast/2
  - enter_loop/1
  - init/1
  - reply/2
  - start/4
  - start_link/4
  - Module:code_change/3
  - Module:handle_call/3
  - Module:handle_cast/2
  - Module:handle_msg/2
  - Module:handle_ssh_msg/2
  - Module:init/1
  - Module:terminate/2
- ssh_server_channel
  - Top of manual page
  - Module:handle_msg/2
  - Module:handle_ssh_msg/2
  - Module:init/1
  - Module:terminate/2
- ssh_connection
  - Top of manual page
  - adjust_window/3
  - close/2
  - exec/4
  - exit_status/3
  - ptty_alloc/3
  - ptty_alloc/4
  - reply_request/4
  - send/3
  - send/4
  - send/4
  - send/5
  - send_eof/2
  - session_channel/2
  - session_channel/4
  - setenv/5
  - shell/2
  - subsystem/4
- ssh_client_key_api
  - Top of manual page
  - Module:add_host_key/3
  - Module:add_host_key/4
  - Module:is_host_key/4
  - Module:is_host_key/5
  - Module:user_key/2
- ssh_server_key_api
  - Top of manual page
  - Module:host_key/2
  - Module:is_auth_key/3
- ssh_file
  - Top of manual page
  - add_host_key/4
  - decode/2
  - decode/2
  - decode/2
  - decode/2
  - encode/2
  - encode/2
  - encode/2
  - host_key/2
  - is_auth_key/3
  - is_host_key/5
  - user_key/2
- ssh_agent
  - Top of manual page
  - add_host_key/3
  - add_host_key/4
  - is_host_key/4
  - is_host_key/5
  - user_key/2
- ssh_sftp
  - Top of manual page
  - apread/4
  - apwrite/4
  - aread/3
  - awrite/3
  - close/2
  - close/3
  - del_dir/2
  - del_dir/3
  - delete/2
  - delete/3
  - list_dir/2
  - list_dir/3
  - make_dir/2
  - make_dir/3
  - make_symlink/3
  - make_symlink/4
  - open/3
  - open/4
  - open_tar/3
  - open_tar/4
  - opendir/2
  - opendir/3
  - position/3
  - position/4
  - pread/4
  - pread/5
  - pwrite/4
  - pwrite/5
  - read/3
  - read/4
  - read_file/2
  - read_file/3
  - read_file_info/2
  - read_file_info/3
  - read_link/2
  - read_link/3
  - read_link_info/2
  - read_link_info/3
  - rename/3
  - rename/4
  - start_channel/1
  - start_channel/2
  - start_channel/1
  - start_channel/2
  - start_channel/3
  - start_channel/1
  - start_channel/2
  - stop_channel/1
  - write/3
  - write/4
  - write_file/3
  - write_file/4
  - write_file_info/3
  - write_file_info/4
- ssh_sftpd
  - Top of manual page
  - subsystem_spec/1

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