# `NervesSSH.Options`
[🔗](https://github.com/nerves-project/nerves_ssh/blob/v1.3.1/lib/nerves_ssh/options.ex#L9)

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](https://erlang.org/doc/man/ssh.html#type-subsystem_spec) 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.

# `language`

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

# `t`

```elixir
@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()}]
}
```

# `add_authorized_key`

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

Add an authorized key

# `add_subsystem`

```elixir
@spec add_subsystem(t(), :ssh.subsystem_spec()) :: t()
```

Add a subsystem

# `add_user`

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

Add user credential to SSH options

# `daemon_options`

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

Return :ssh.daemon_options()

# `decode_authorized_keys`

```elixir
@spec decode_authorized_keys(t()) :: t()
```

Decode the authorized keys into Erlang public key format

# `load_authorized_keys`

```elixir
@spec load_authorized_keys(t()) :: t()
```

Load authorized keys from the authorized_keys file

# `new`

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

Convert keyword options to the NervesSSH.Options

# `remove_authorized_key`

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

Remove an authorized key

# `remove_subsystem`

```elixir
@spec remove_subsystem(
  t(),
  charlist()
) :: t()
```

Remove a subsystem

# `remove_user`

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

Remove user credential from SSH options

# `sanitize`

```elixir
@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`

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

Save the authorized keys to authorized_keys file

# `with_defaults`

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

Create a new NervesSSH.Options and fill in defaults

---

*Consult [api-reference.md](api-reference.md) for complete listing*
