note 121969 added to function.ssh2-connect
| From: | christophermjgray at gmail dot com | Date: | Sat, 02 Dec 2017 22:01:19 +0000 |
| Subject: | note 121969 added to function.ssh2-connect | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-209302@lists.php.net to get a copy of this message | ||
This page is out of date. Any of the SHA-1 in the Key Exchange Methods in the kex section should be
discarded, due to Logjam (https://weakdh.org/logjam.html). If you continue to use them, connects
will result in the following warning:
"Warning: ssh2_connect(): Error starting up SSH connection(-5): Unable to exchange encryption
keys in ..."
The following is an example of what works. Also by removing the 'hex' section all
together, results in libssl (https://libssh2.org/) falling back to discovering which is the
strongest cipher to authenticate with.
<?php
if (!function_exists("ssh2_connect")) die("function ssh2_connect doesn't
exist");
function ssh2_debug($message, $language, $always_display) {
printf("%s %s %s\n",$message,$language,$always_display);
}
/* 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(
'hostkey'=>'ssh-rsa,ssh-dss',
// 'kex' => 'diffie-hellman-group-exchange-sha256',
'client_to_server' => array(
'crypt' =>
'aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,3des-cbc,blowfish-cbc',
'comp' => 'none'),
'server_to_client' => array(
'crypt' =>
'aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,3des-cbc,blowfish-cbc',
'comp' => 'none'));
$callbacks = array('disconnect' => 'my_ssh_disconnect');
foreach (array('192.168.1.1') as $host) {
$connection = ssh2_connect($host, 22, $methods, $callbacks);
if (!$connection) die("Connection failed:");
ssh2_auth_password($connection, 'user', 'my_password') or die("Unable to
authenticate");
$stream = ssh2_exec($connection, 'free -m');
stream_set_blocking($stream, true);
$stream_out = ssh2_fetch_stream($stream, SSH2_STREAM_STDIO);
echo stream_get_contents($stream_out);
}
?>
----
Server IP: 208.43.231.9
Probable Submitter: 73.160.147.229
----
Manual Page -- http://php.net/manual/en/function.ssh2-connect.php
Edit -- https://master.php.net/note/edit/121969
Del: integrated -- https://master.php.net/note/delete/121969/integrated
Del: useless -- https://master.php.net/note/delete/121969/useless
Del: bad code -- https://master.php.net/note/delete/121969/bad+code
Del: spam -- https://master.php.net/note/delete/121969/spam
Del: non-english -- https://master.php.net/note/delete/121969/non-english
Del: in docs -- https://master.php.net/note/delete/121969/in+docs
Del: other reasons-- https://master.php.net/note/delete/121969
Reject -- https://master.php.net/note/reject/121969
Search -- https://master.php.net/manage/user-notes.php