-
Notifications
You must be signed in to change notification settings - Fork 788
/
Copy pathssh2-connect.xml
329 lines (319 loc) · 10.1 KB
/
ssh2-connect.xml
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
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://docbook.org/ns/docbook" xml:id="function.ssh2-connect">
<refnamediv>
<refname>ssh2_connect</refname>
<refpurpose>Connect to an SSH server</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type class="union"><type>resource</type><type>false</type></type><methodname>ssh2_connect</methodname>
<methodparam><type>string</type><parameter>host</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>port</parameter><initializer>22</initializer></methodparam>
<methodparam choice="opt"><type>array</type><parameter>methods</parameter></methodparam>
<methodparam choice="opt"><type>array</type><parameter>callbacks</parameter></methodparam>
</methodsynopsis>
<para>
Establish a connection to a remote SSH server.
</para>
<para>
Once connected, the client should verify the server's hostkey using
<function>ssh2_fingerprint</function>, then authenticate using either
password or public key.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>host</parameter></term>
<listitem>
<para>
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>port</parameter></term>
<listitem>
<para>
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>methods</parameter></term>
<listitem>
<para>
<parameter>methods</parameter> may be an associative array with up to four parameters
as described below.
</para>
<para>
<table>
<title><parameter>methods</parameter> may be an associative array
with any or all of the following parameters.</title>
<tgroup cols="3">
<thead>
<row>
<entry>Index</entry>
<entry>Meaning</entry>
<entry>Supported Values*</entry>
</row>
</thead>
<tbody>
<row>
<entry>kex</entry>
<entry>
List of key exchange methods to advertise, comma separated
in order of preference.
</entry>
<entry>
<literal>diffie-hellman-group1-sha1</literal>,
<literal>diffie-hellman-group14-sha1</literal>, and
<literal>diffie-hellman-group-exchange-sha1</literal>
</entry>
</row>
<row>
<entry>hostkey</entry>
<entry>
List of hostkey methods to advertise, comma separated
in order of preference.
</entry>
<entry>
<literal>ssh-rsa</literal> and
<literal>ssh-dss</literal>
</entry>
</row>
<row>
<entry>client_to_server</entry>
<entry>
Associative array containing crypt, compression, and
message authentication code (MAC) method preferences
for messages sent from client to server.
</entry>
<entry/>
</row>
<row>
<entry>server_to_client</entry>
<entry>
Associative array containing crypt, compression, and
message authentication code (MAC) method preferences
for messages sent from server to client.
</entry>
<entry/>
</row>
</tbody>
</tgroup>
</table>
</para>
<para>
* - Supported Values are dependent on methods supported by underlying library.
See <link xlink:href="&url.libssh2;">libssh2</link> documentation for additional
information.
</para>
<para>
<table>
<title>
<parameter>client_to_server</parameter> and
<parameter>server_to_client</parameter> may be an associative array
with any or all of the following parameters.
</title>
<tgroup cols="3">
<thead>
<row>
<entry>Index</entry>
<entry>Meaning</entry>
<entry>Supported Values*</entry>
</row>
</thead>
<tbody>
<row>
<entry>crypt</entry>
<entry>List of crypto methods to advertise, comma separated
in order of preference.</entry>
<entry>
<literal>[email protected]</literal>,
<literal>aes256-cbc</literal>,
<literal>aes192-cbc</literal>,
<literal>aes128-cbc</literal>,
<literal>3des-cbc</literal>,
<literal>blowfish-cbc</literal>,
<literal>cast128-cbc</literal>,
<literal>arcfour</literal>, and
<literal>none**</literal>
</entry>
</row>
<row>
<entry>comp</entry>
<entry>List of compression methods to advertise, comma separated
in order of preference.</entry>
<entry>
<literal>zlib</literal> and
<literal>none</literal>
</entry>
</row>
<row>
<entry>mac</entry>
<entry>List of MAC methods to advertise, comma separated
in order of preference.</entry>
<entry>
<literal>hmac-sha1</literal>,
<literal>hmac-sha1-96</literal>,
<literal>hmac-ripemd160</literal>,
<literal>[email protected]</literal>, and
<literal>none**</literal>
</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
<para>
<note>
<title>Crypt and MAC method "<literal>none</literal>"</title>
<para>
For security reasons, <literal>none</literal> is disabled by the underlying
<link xlink:href="&url.libssh2;">libssh2</link> library unless explicitly enabled
during build time by using the appropriate ./configure options. See documentation
for the underlying library for more information.
</para>
</note>
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>callbacks</parameter></term>
<listitem>
<para>
<parameter>callbacks</parameter> may be an associative array with any
or all of the following parameters.
<table>
<title>
Callbacks parameters
</title>
<tgroup cols="3">
<thead>
<row>
<entry>Index</entry>
<entry>Meaning</entry>
<entry>Prototype</entry>
</row>
</thead>
<tbody>
<row>
<entry>ignore</entry>
<entry>
Name of function to call when an
<constant>SSH2_MSG_IGNORE</constant> packet is received
</entry>
<entry>void ignore_cb($message)</entry>
</row>
<row>
<entry>debug</entry>
<entry>
Name of function to call when an
<constant>SSH2_MSG_DEBUG</constant> packet is received
</entry>
<entry>void debug_cb($message, $language, $always_display)</entry>
</row>
<row>
<entry>macerror</entry>
<entry>
Name of function to call when a packet is received but the
message authentication code failed. If the callback returns
&true;, the mismatch will be ignored, otherwise the connection
will be terminated.
</entry>
<entry>bool macerror_cb($packet)</entry>
</row>
<row>
<entry>disconnect</entry>
<entry>
Name of function to call when an
<constant>SSH2_MSG_DISCONNECT</constant> packet is received
</entry>
<entry>void disconnect_cb($reason, $message, $language)</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns a resource on success, or &false; on error.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>ssh2_connect</function> example</title>
<para>
Open a connection forcing 3des-cbc when sending packets, any strength
aes cipher when receiving packets, no compression in either direction,
and Group1 key exchange.
</para>
<programlisting role="php">
<![CDATA[
<?php
/* Notify the user if the server terminates the connection */
function my_ssh_disconnect($reason, $message, $language) {
printf("Server disconnected with reason code [%d] and message: %s\n",
$reason, $message);
}
$methods = array(
'kex' => 'diffie-hellman-group1-sha1',
'client_to_server' => array(
'crypt' => '3des-cbc',
'comp' => 'none'),
'server_to_client' => array(
'crypt' => 'aes256-cbc,aes192-cbc,aes128-cbc',
'comp' => 'none'));
$callbacks = array('disconnect' => 'my_ssh_disconnect');
$connection = ssh2_connect('shell.example.com', 22, $methods, $callbacks);
if (!$connection) die('Connection failed');
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>ssh2_fingerprint</function></member>
<member><function>ssh2_auth_none</function></member>
<member><function>ssh2_auth_password</function></member>
<member><function>ssh2_auth_pubkey_file</function></member>
<member><function>ssh2_disconnect</function></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->