ssh_client_key_api v0.2.0 SSHClientKeyAPI View Source

Simple wrapper for the Erlang :ssh_client_key_api behavior, to make it easier to specify SSH keys and known_hosts files independently of any particular user’s home directory

It is meant to primarily be used via the convenience function with_options:

key = File.open!("path/to/keyfile")
known_hosts = File.open!("path/to/known_hosts")
cb = SSHClientKeyAPI.with_options(identity: key, known_hosts: known_hosts, silently_accept_hosts: true)

The result can be passed as an option when creating an SSHKit.SSH.Connection:

SSHKit.SSH.connect("example.com", key_cb: cb)
  • identity: IO.device providing the ssh key (required)
  • known_hosts: IO.device providing the known hosts list. If providing a File IO, it should have been opened in :write mode (required)
  • silently_accept_hosts: boolean silently accept and add new hosts to the known hosts. By default only known hosts will be accepted.

Link to this section Summary

Functions

Callback implementation for c::ssh_client_key_api.add_host_key/3

Callback implementation for c::ssh_client_key_api.is_host_key/4

Callback implementation for c::ssh_client_key_api.user_key/2

returns a tuple suitable for passing the SSHKit.SSH.Connect as the key_cb option

Link to this section Functions

Link to this function add_host_key(hostname, key, opts) View Source

Callback implementation for c::ssh_client_key_api.add_host_key/3.

Link to this function is_host_key(key, hostname, alg, opts) View Source

Callback implementation for c::ssh_client_key_api.is_host_key/4.

Callback implementation for c::ssh_client_key_api.user_key/2.

Link to this function with_options(opts \\ []) View Source
with_options(opts :: list()) :: {atom(), list()}

returns a tuple suitable for passing the SSHKit.SSH.Connect as the key_cb option.

### Options

  • identity: IO.device providing the ssh key (required)
  • known_hosts: IO.device providing the known hosts list. If providing a File IO, it should have been opened in :write mode (required)
  • silently_accept_hosts: boolean silently accept and add new hosts to the known hosts. By default only known hosts will be accepted.
  • passphrase : binary passphrase if your key is protected (optional)

    by default it will use the the files found in System.user_home!

    ### Example

  key = File.open!("path/to/keyfile")
  known_hosts = File.open!("path/to/known_hosts")
  cb = SSHClientKeyAPI.with_options(identity: key, known_hosts: known_hosts)
  SSHKit.SSH.connect("example.com", key_cb: cb)