View Source NervesSSH.Options (nerves_ssh v1.0.0)

Defines option for running the SSH daemon.

The following fields are available:

  • :name - a name used to reference the NervesSSH-managed SSH daemon. Defaults to NervesSSH.
  • :authorized_keys - a list of SSH authorized key file string
  • :port - the TCP port to use for the SSH daemon. Defaults to 22.
  • :subsystems - a list of SSH subsystems specs to start. Defaults to SFTP and ssh_subsystem_fwup
  • :user_dir - where to find authorized_keys file
  • :system_dir - where to find host keys
  • :shell - the language of the shell (:elixir, :erlang, :lfe or :disabled). Defaults to :elixir.
  • :exec - the language to use for commands sent over ssh (:elixir, :erlang, or :disabled). Defaults to :elixir.
  • :iex_opts - additional options to use when starting up IEx
  • :user_passwords - a list of username/password tuples (stored in the clear!)
  • :daemon_option_overrides - additional options to pass to :ssh.daemon/2. These take precedence and are unchecked. Be careful using this since it can break other options.

Summary

Functions

Add an authorized key

Add user credential to SSH options

Return :ssh.daemon_options()

Decode the authorized keys into Erlang public key format

Load authorized keys from the authorized_keys file

Convert keyword options to the NervesSSH.Options

Remove an authorized key

Remove user credential from SSH options

Go through the options and fix anything that might crash

Save the authorized keys to authorized_keys file

Create a new NervesSSH.Options and fill in defaults

Types

@type language() :: :elixir | :erlang | :lfe | :disabled
@type t() :: %NervesSSH.Options{
  authorized_keys: [String.t()],
  daemon_option_overrides: keyword(),
  decoded_authorized_keys: [:public_key.public_key()],
  exec: language(),
  iex_opts: keyword(),
  name: GenServer.name(),
  port: non_neg_integer(),
  shell: language(),
  subsystems: [:ssh.subsystem_spec()],
  system_dir: Path.t(),
  user_dir: Path.t(),
  user_passwords: [{String.t(), String.t()}]
}

Functions

Link to this function

add_authorized_key(opts, key)

View Source
@spec add_authorized_key(t(), String.t()) :: t()

Add an authorized key

Link to this function

add_user(opts, user, password)

View Source
@spec add_user(t(), String.t(), String.t() | nil) :: t()

Add user credential to SSH options

@spec daemon_options(t()) :: :ssh.daemon_options()

Return :ssh.daemon_options()

Link to this function

decode_authorized_keys(opts)

View Source
@spec decode_authorized_keys(t()) :: t()

Decode the authorized keys into Erlang public key format

Link to this function

load_authorized_keys(opts)

View Source
@spec load_authorized_keys(t()) :: t()

Load authorized keys from the authorized_keys file

@spec new(keyword()) :: t()

Convert keyword options to the NervesSSH.Options

Link to this function

remove_authorized_key(opts, key)

View Source
@spec remove_authorized_key(t(), String.t()) :: t()

Remove an authorized key

@spec remove_user(t(), String.t()) :: t()

Remove user credential from SSH options

@spec sanitize(t()) :: t()

Go through the options and fix anything that might crash

The goal is to make options "always work" since it is painful to debug typo's, etc. that cause the ssh daemon to not start.

Link to this function

save_authorized_keys(opts)

View Source
@spec save_authorized_keys(t()) :: :ok | {:error, File.posix()}

Save the authorized keys to authorized_keys file

Link to this function

with_defaults(opts \\ [])

View Source
@spec with_defaults(keyword()) :: t()

Create a new NervesSSH.Options and fill in defaults