View Source NervesSSH.Options (nerves_ssh v1.0.1)

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

language()

@type language() :: :elixir | :erlang | :lfe | :disabled

t()

@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

add_authorized_key(opts, key)

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

Add an authorized key

add_user(opts, user, password)

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

Add user credential to SSH options

daemon_options(opts)

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

Return :ssh.daemon_options()

decode_authorized_keys(opts)

@spec decode_authorized_keys(t()) :: t()

Decode the authorized keys into Erlang public key format

load_authorized_keys(opts)

@spec load_authorized_keys(t()) :: t()

Load authorized keys from the authorized_keys file

new(opts \\ [])

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

Convert keyword options to the NervesSSH.Options

remove_authorized_key(opts, key)

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

Remove an authorized key

remove_user(opts, user)

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

Remove user credential from SSH options

sanitize(opts)

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

save_authorized_keys(opts)

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

Save the authorized keys to authorized_keys file

with_defaults(opts \\ [])

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

Create a new NervesSSH.Options and fill in defaults