1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
|
.TH ssh_cm 3 "ssh 0.9.9.6" "Ericsson AB" "ERLANG MODULE DEFINITION"
.SH MODULE
ssh_cm \- SSH connection layer\&.
.SH DESCRIPTION
.LP
This module implements the SSH connection layer\&.
.SH EXPORTS
.LP
.B
connect(Host) -> {ok, Pid} | {error, Error}
.br
.B
connect(Host, Options) -> {ok, Pid} | {error, Error}
.br
.B
connect(Host, Port, Options) -> {ok, Pid} | {error, Error}
.br
.RS
.TP
Types
Host = string()
.br
Port = integer()
.br
Options = [{Option, Value}]
.br
.RE
.RS
.LP
Connects to an SSH server\&. A \fIgen_server\fR is started and returned if connection is successful, but no channel is started, that is done with \fIsession_open/2\fR\&. The \fIHost\fR is a string with the address of a host running an SSH server\&. The \fIPort\fR is an integer, the port to connect to\&. The default is \fI22\fR, the registered port for SSH\&.
.LP
Options are:
.RS 2
.TP 4
.B
\fI{user_dir, String}\fR:
Sets the user directory, normally \fI~/\&.ssh\fR (containing the files \fIknown_hosts\fR, \fIid_rsa<c>, <c>id_dsa\fR, \fIauthorized_keys\fR)\&.
.TP 4
.B
\fI{silently_accept_hosts, Boolean}\fR:
When true, (default is false), hosts are added to the file \fIknown_hosts\fR without asking the user\&.
.TP 4
.B
\fI{user_interaction, Boolean}\fR:
If true, which is the default, password questions and adding hosts to \fIknown_hosts\fR will be asked interactively to the user\&. (This is done during connection to an SSH server\&.) If false, both these interactions will throw and the server will not start\&.
.TP 4
.B
\fI{public_key_alg, ssh_rsa | ssh_dsa}\fR:
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 \fIssh_rsa\fR first\&.
.TP 4
.B
\fI{connect_timeout, Milliseconds | infinity}\fR:
Sets the default timeout when trying to connect to an SSH server\&. This timeout will also affect calls later when using the SSH connection\&.
.TP 4
.B
\fI{user, String}\fR:
Provide a username\&. If this option is not given, ssh reads from the environment (\fILOGNAME\fR or \fIUSER\fR on unix, \fIUSERNAME\fR on Windows)\&.
.TP 4
.B
\fI{password, String}\fR:
Provide a password for password authentication\&. If this option is not given, the user will be asked for a password\&.
.TP 4
.B
\fI{user_auth, Fun/3}\fR:
Provide a fun for password authentication\&. The fun will be called as \fIfun(User, Password, Opts)\fR and should return \fItrue\fR or \fIfalse\fR\&.
.TP 4
.B
\fI{key_cb, KeyCallbackModule}\fR:
Provide a special call-back module for key handling\&. The call-back module should be modeled after the \fIssh_file\fR module\&. The function that must be exported are: \fIprivate_host_rsa_key/2\fR, \fIprivate_host_dsa_key/2\fR, \fIlookup_host_key/3\fR and \fIadd_host_key/3\fR\&.
.TP 4
.B
\fI{fd, FD}\fR:
Allow an existing file-descriptor to be used, given in FD\&. (Simply passed on to gen_tcp:listen\&.)
.RE
.LP
As usual, boolean options that should be \fItrue\fR can be given as an atom instead of a tuple, e\&.g\&. \fIsilently_accept_hosts\fR instead of \fI{silently_accept_hosts, true}\fR\&.
.RE
.LP
.B
listen(UserFun, Options) -> ok
.br
.B
listen(UserFun, Port, Options) -> ok
.br
.B
listen(UserFun, Addr, Port, Options) -> ok
.br
.RS
.TP
Types
UserFun = fun() -> Pid
.br
Port = integer()
.br
Addr = string() | any
.br
Options = [{Option, Value}]
.br
Option = atom()
.br
Value = term()
.br
.RE
.RS
.LP
Starts a server listening for SSH connections on the given port\&.
.LP
\fIUserFun\fR is a function that should spawn and return a server upon incoming connections on the given port (and address)\&.
.LP
\fIPort\fR is the port that the server should listen on\&. Everytime a connection is made on that port, the \fIUserFun\fR is called, and the returned process is used as a user process for the server\&.
.LP
Options are:
.RS 2
.TP 4
.B
\fI{system_dir, String}\fR:
Sets the system directory, containing the host files that identifies the host for ssh\&. The default is \fI/etc/ssh\fR, but note that SSH normally requires the host files there to be readable only by root\&.
.TP 4
.B
\fI{user_passwords, [{User, Password}]}\fR:
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\&. \fIUser\fR and \fIPassword\fR are strings\&.
.TP 4
.B
\fI{password, String}\fR:
Provide a global password that will authenticate any user (use with caution!)\&.
.RS 4
.LP
.LP
If neither of these options is given, the server will be unable to authenticate with password\&.
.RE
.TP 4
.B
\fI{pwdfun, fun/2}\fR:
Provide a function for password validation\&. This is called with user and password as strings, and should return \fItrue\fR if the password is valid and \fIfalse\fR otherwise\&.
.TP 4
.B
\fI{fd, FD}\fR:
Allow an existing file-descriptor to be used, given in FD\&. (Simply passed on to gen_tcp:listen\&.)
.RE
.RE
.LP
.B
stop_listener(Pid) -> ok | {error, Reason}
.br
.RS
.TP
Types
Pid = pid()
.br
Reason = atom()
.br
.RE
.RS
.LP
Stops the listener, given by \fIPid\fR, existing connections will stay open\&.
.RE
|