# ssh_cli

### MODULE

ssh_cli

### MODULE SUMMARY

SSH Command Line Interface.

### DESCRIPTION

This module implements a CLI (Command Line Interface), for an SSH server. It's used by `ssh_sshd` to provide an interactive erlang shell as an ssh server.

Since `ssh_cli` uses the `group` module, the CLI provides full editing just like in the erlang shell, with history (ctrl-p and ctrl-n), line editing and configurable tab expansion (completion).

A full example of how to use `ssh_cli` is provided in `ssh/examples/ssh_sample_cli.erl`.

### EXPORTS

`listen(Shell)`
`listen(Shell, Port)`
`listen(Shell, Port, Options)`
`listen(Shell, Addr, Port, Options)`

Types:

`Shell = pid() | fun()`
`Port = integer()`
`Addr = string()`
`Options = [{Option, Value}]`
`Option = atom()`
`Value = term()`

Starts a daemon listening on `Port`. The `Shell` fun is a function spawning a shell process, containing a read-eval-print-loop using ordinary erlang `io` (e.g. `get_line/1` and `fprint`).

The daemon's group leader will be connected to the SSH daemon, so that the io will be sent to the remote SSH shell client.

An example of how `ssh_cli` can be used can be found in `ssh/examples/ssh_cli_sample.erl`.

The module `ssh_sshd` is implemented using `ssh_cli`.

Options are:

{expand_fun, Fun}
  Provide a function for tab-completion (expansion) like the erlang shell. This function is called when the user presses the Tab key, and can return expansion.
  The function is called with the current line, upto the cursor, as a reversed string. It should return a three-tuple: `{yes|no, string(), [string(), ...]}`. The first element gives a beep if `no`, otherwise the expansion is silent, the second is a string that will be entered at the cursor position, and the third is a list of possible expansions. If this list is non-empty, the list will be printed and the current input line will be written once again.

For more options, see `ssh_cm:listen`.

`stop(Pid) -> ok | {error, Reason}`

Types:

`Pid = pid()`
`Reason = atom()`

Stops the listener given by `Pid`, existing connections will stay open.

### AUTHORS

Jakob Cederlund - support@erlang.ericsson.se

ssh 0.9
Copyright © 1991-2005 Ericsson AB