[Ericsson AB]

SSH

MODULE

ssh

MODULE SUMMARY

Main API of the SSH application

DESCRIPTION

Interface module for the SSH application

COMMON DATA TYPES

Type definitions that are used more than once in this module:

boolean() = true | false

string() = list of ASCII characters

ssh_system_ref() - opaque to the user returned by connect/[1,2,3]

ssh_connection_ref() - opaque to the user returned by listner/[]

ip_address() - {N1,N2,N3,N4} % IPv4 | {K1,K2,K3,K4,K5,K6,K7,K8} % IPv6

child_spec() - A child process specification see supervisor(3)

EXPORTS

close(ConnectionRef) ->

Types:

ConnectionRef = ssh_connection_ref()

Closed a ssh connection.

connect(Host) ->
connect(Host, Options) ->
connect(Host, Port, Options) -> {ok, ssh_connection_ref()} | {error, Reason}

Types:

Host = string()
Port = integer()

The default is 22, the registered port for SSH.
Options = [{Option, Value}]

Connects to an SSH server. No channel is started this is done by calling ssh_connect:session_cahnnel/2.

Options are:

{user_dir, String}
Sets the user directory, normally ~/.ssh (containing the files known_hosts, id_rsa<c>, <c>id_dsa, authorized_keys).
{silently_accept_hosts, Boolean}
When true, (default is false), hosts are added to the file known_hosts without asking the user.
{user_interaction, Boolean}
If true, which is the default, password questions and adding hosts to known_hosts will be asked interactively to the user, if they are not suppressed by other options. (This is done during connection to an SSH server.) If false, both these events will throw and exception and the server will not start.
{public_key_alg, ssh_rsa | ssh_dsa}
Sets the preferred public key algorithm to use for user authentication. If the the preferred algorithm fails of some reason, the other algorithm is tried. The default is to try ssh_rsa first.
{connect_timeout, Milliseconds | infinity}
Sets the default timeout when trying to connect to.
{user, String}
Provide a username. If this option is not given, ssh reads from the environment (LOGNAME or USER on unix, USERNAME on Windows).
{password, String}
Provide a password for password authentication. If this option is not given, the user will be asked for a password if the password authentication method is attempted.
{user_auth, Fun/3}
Provide a fun for password authentication. The fun will be called as fun(User, Password, Opts) and should return true or false.
{key_cb, KeyCallbackModule}
Provide a special call-back module for key handling. The call-back module should be modeled after the ssh_file module. The function that must be exported are: private_host_rsa_key/2, private_host_dsa_key/2, lookup_host_key/3 and add_host_key/3.
{fd, FD}
Allow an existing file-descriptor to be used, given in FD. (Simply passed on to gen_tcp:connect.)

daemon(Port) ->
daemon(Port, Options) ->
daemon(HostAddress, Port, Options) -> ssh_system_ref()

Types:

Port = integer()
HostAddress = ip_address() | any
Options = [{Option, Value}]
Option = atom()
Value = term()

Starts a server listening for SSH connections on the given port.

Options are:

{subsystems, [{SubSysName, child_spec()}]}
Provides child specificatoions for handled subsystems. By default sftp is a handled subsystems.
{shell, {Module, Function, Args} | fun()}
Defines what command line interface to use. Exampe use the erlang shell: {shell, start, []}) which is the dafault behavior.
{system_dir, String}
Sets the system directory, containing the host files that identifies the host for ssh. The default is /etc/ssh, but note that SSH normally requires the host files there to be readable only by root.
{user_passwords, [{User, Password}]}
Provide passwords for password authentication.They will be used when someone tries to connect to the server and public key user autentication fails. The option provides a list of valid user names and the corresponding password. User and Password are strings.
{password, String}
Provide a global password that will authenticate any user (use with caution!).
{pwdfun, fun/2}
Provide a function for password validation. This is called with user and password as strings, and should return true if the password is valid and false otherwise.
{fd, FD}
Allow an existing file-descriptor to be used, given in FD. (Simply passed on to gen_tcp:listen.)

shell(Host) ->
shell(Host, Option) ->
shell(Host, Port, Option) -> _

Types:

Host = string()
Port = integer()
Options - see ssh:connect/[1,2,3]

Starts an interactive shell to an SSH server on the given Host. The function waits for user input, and will not return until the remote shell is ended.(e.g. on exit from the shell)

start() ->
start(Type) -> ok | {error, Reason}

Types:

Type = permanent | transient | temporary
Reason = term()

Starts the Ssh application. Default type is temporary. See also application(3) Requiers that the crypto application has been started.

stop() -> ok

Stops the Ssh application. See also application(3)

stop_daemon(SysRef) ->
stop_daemon(Address, Port) -> ok

Types:

SysRef = ssh_system_ref()
Address = ip_address()
Port = integer()

Stops the listener and all connections started by the listener.

stop_listener(SysRef) ->
stop_listener(Address, Port) -> ok

Types:

SysRef = ssh_system_ref()
Address = ip_address()
Port = integer()

Stops the listener, but leaves existing connections started by the listener up and running.


ssh 1.0
Copyright © 1991-2008 Ericsson AB