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 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!-- This document was generated using DocBuilder 3.3.3 -->
<HTML>
<HEAD>
<TITLE>ssh_cm</TITLE>
<SCRIPT type="text/javascript" src="../../../../doc/erlresolvelinks.js">
</SCRIPT>
<STYLE TYPE="text/css">
<!--
.REFBODY { margin-left: 13mm }
.REFTYPES { margin-left: 8mm }
-->
</STYLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#FF00FF"
ALINK="#FF0000">
<!-- refpage -->
<CENTER>
<A HREF="http://www.erlang.se">
<IMG BORDER=0 ALT="[Ericsson AB]" SRC="min_head.gif">
</A>
<H1>ssh_cm</H1>
</CENTER>
<H3>MODULE</H3>
<DIV CLASS=REFBODY>
ssh_cm
</DIV>
<H3>MODULE SUMMARY</H3>
<DIV CLASS=REFBODY>
SSH connection layer.
</DIV>
<H3>DESCRIPTION</H3>
<DIV CLASS=REFBODY>
<P> This module implements the SSH connection layer.
</DIV>
<H3>EXPORTS</H3>
<P><A NAME="connect/1"><STRONG><CODE>connect(Host) -> {ok, Pid} | {error, Error}</CODE></STRONG></A><BR>
<A NAME="connect/2"><STRONG><CODE>connect(Host, Options) -> {ok, Pid} | {error, Error}</CODE></STRONG></A><BR>
<A NAME="connect/3"><STRONG><CODE>connect(Host, Port, Options) -> {ok, Pid} | {error, Error}</CODE></STRONG></A><BR>
<DIV CLASS=REFBODY><P>Types:
<DIV CLASS=REFTYPES>
<P>
<STRONG><CODE>Host = string()</CODE></STRONG><BR>
<STRONG><CODE>Port = integer()</CODE></STRONG><BR>
<STRONG><CODE>Options = [{Option, Value}]</CODE></STRONG><BR>
</DIV>
</DIV>
<DIV CLASS=REFBODY>
<P>Connects to an SSH server. A <CODE>gen_server</CODE> is started and
returned if connection is successful, but no channel is started,
that is done with <CODE>session_open/2</CODE>. The <CODE>Host</CODE> is a
string with the address of a host running an SSH server. The
<CODE>Port</CODE> is an integer, the port to connect to. The default
is <CODE>22</CODE>, the registered port for SSH.
<P>Options are:
<P>
<DL>
<DT>
<CODE>{user_dir, String}</CODE>
</DT>
<DD>
Sets the user directory, normally
<CODE>~/.ssh</CODE> (containing the files
<CODE>known_hosts</CODE>, <CODE>id_rsa<c>, <c>id_dsa</CODE>,
<CODE>authorized_keys</CODE>).<BR>
</DD>
<DT>
<CODE>{silently_accept_hosts, Boolean}</CODE>
</DT>
<DD>
When true, (default is false), hosts are added to the
file <CODE>known_hosts</CODE> without asking the user.<BR>
</DD>
<DT>
<CODE>{user_interaction, Boolean}</CODE>
</DT>
<DD>
If true, which is the default, password questions
and adding hosts to <CODE>known_hosts</CODE> 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.<BR>
</DD>
<DT>
<CODE>{public_key_alg, ssh_rsa | ssh_dsa}</CODE>
</DT>
<DD>
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 <CODE>ssh_rsa</CODE> first.<BR>
</DD>
<DT>
<CODE>{connect_timeout, Milliseconds | infinity}</CODE>
</DT>
<DD>
Sets the default timeout when trying to connect to
an SSH server. This timeout will also affect calls
later when using the SSH connection.<BR>
</DD>
<DT>
<CODE>{user, String}</CODE>
</DT>
<DD>
Provide a username. If this option is not given,
ssh reads from the environment (<CODE>LOGNAME</CODE> or
<CODE>USER</CODE> on unix, <CODE>USERNAME</CODE> on Windows).<BR>
</DD>
<DT>
<CODE>{password, String}</CODE>
</DT>
<DD>
Provide a password for password authentication.
If this option is not given, the user will be asked
for a password.<BR>
</DD>
<DT>
<CODE>{user_auth, Fun/3}</CODE>
</DT>
<DD>
Provide a fun for password authentication. The fun
will be called as <CODE>fun(User, Password, Opts)</CODE> and
should return <CODE>true</CODE> or <CODE>false</CODE>.<BR>
</DD>
<DT>
<CODE>{key_cb, KeyCallbackModule}</CODE>
</DT>
<DD>
Provide a special call-back module for key handling.
The call-back module should be modeled after the
<CODE>ssh_file</CODE> module. The function that must be
exported are: <CODE>private_host_rsa_key/2</CODE>,
<CODE>private_host_dsa_key/2</CODE>, <CODE>lookup_host_key/3</CODE>
and <CODE>add_host_key/3</CODE>.
<BR>
</DD>
</DL>
<P>As usual, boolean options that should be <CODE>true</CODE> can be
given as an atom instead of a tuple, e.g.
<CODE>silently_accept_hosts</CODE> instead of
<CODE>{silently_accept_hosts, true}</CODE>.
</DIV>
<P><A NAME="listen/2"><STRONG><CODE>listen(UserFun, Options) -> ok</CODE></STRONG></A><BR>
<A NAME="listen/3"><STRONG><CODE>listen(UserFun, Port, Options) -> ok</CODE></STRONG></A><BR>
<A NAME="listen/4"><STRONG><CODE>listen(UserFun, Addr, Port, Options) -> ok</CODE></STRONG></A><BR>
<DIV CLASS=REFBODY><P>Types:
<DIV CLASS=REFTYPES>
<P>
<STRONG><CODE>UserFun = fun() -> Pid</CODE></STRONG><BR>
<STRONG><CODE>Port = integer()</CODE></STRONG><BR>
<STRONG><CODE>Addr = string() | any</CODE></STRONG><BR>
<STRONG><CODE>Options = [{Option, Value}]</CODE></STRONG><BR>
<STRONG><CODE>Option = atom()</CODE></STRONG><BR>
<STRONG><CODE>Value = term()</CODE></STRONG><BR>
</DIV>
</DIV>
<DIV CLASS=REFBODY>
<P>Starts a server listening for SSH connections on the given port.
<P><CODE>UserFun</CODE> is a function that should spawn and return a server
upon incoming connections on the given port (and address).
<P><CODE>Port</CODE> is the port that the server should listen on.
Everytime a connection is made on that port, the <CODE>UserFun</CODE> is
called, and the returned process is used as a user process
for the server.
<P>Options are:
<P>
<DL>
<DT>
<CODE>{system_dir, String}</CODE>
</DT>
<DD>
Sets the system directory, containing the host files that
identifies the host for ssh. The default is <CODE>/etc/ssh</CODE>,
but note that SSH normally requires the host files there to
be readable only by root.<BR>
</DD>
<DT>
<CODE>{user_passwords, [{User, Password}]}</CODE>
</DT>
<DD>
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.
<CODE>User</CODE> and <CODE>Password</CODE> are strings.<BR>
</DD>
<DT>
<CODE>{password, String}</CODE>
</DT>
<DD>
Provide a global password that will authenticate any
user (use with caution!).<BR>
If neither of these options is given, the server will
be unable to authenticate with password.<BR>
</DD>
</DL>
</DIV>
<P><A NAME="stop_listener/1"><STRONG><CODE>stop_listener(Pid) -> ok | {error, Reason}</CODE></STRONG></A><BR>
<DIV CLASS=REFBODY><P>Types:
<DIV CLASS=REFTYPES>
<P>
<STRONG><CODE>Pid = pid()</CODE></STRONG><BR>
<STRONG><CODE>Reason = atom()</CODE></STRONG><BR>
</DIV>
</DIV>
<DIV CLASS=REFBODY>
<P>Stops the listener, given by <CODE>Pid</CODE>, existing
connections will stay open.
</DIV>
<H3>AUTHORS</H3>
<DIV CLASS=REFBODY>
Jakob Cederlund - support@erlang.ericsson.se<BR>
</DIV>
<CENTER>
<HR>
<SMALL>ssh 0.9.5<BR>
Copyright © 1991-2006
<A HREF="http://www.erlang.se">Ericsson AB</A><BR>
</SMALL>
</CENTER>
</BODY>
</HTML>
|