ssh2_connect
ssh2_connect
Connect to an SSH server
**ssh2_connect** string $host int $port array $methods array $callbacks
Establish a connection to a remote SSH server.
Once connected, the client should verify the server's hostkey using
, then authenticate using either
password or public key.
ssh2_fingerprint
host
port
methods
may be an associative array with up to four parameters
as described below.
methods
* - Supported Values are dependent on methods supported by underlying library.
See documentation for additional
information.
libssh2
Opmerking: > ### Crypt and MAC method "none"
For security reasons, is disabled by the underlying library unless explicitly enabled during build time by using the appropriate ./configure options. See documentation for the underlying library for more information. `none`libssh2
callbacks
may be an associative array with any
or all of the following parameters.
`callbacks`
Returns a resource on success, or false on error.
Voorbeeld: example
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.
<?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');
?>
ssh2_fingerprint``ssh2_auth_none``ssh2_auth_password``ssh2_auth_pubkey``ssh2_auth_pubkey_file``ssh2_disconnect