php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80609 ssh2_connect fails
Submitted: 2021-01-09 18:22 UTC Modified: 2021-02-09 18:19 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: dev at springtimesoftware dot com Assigned: cmb (profile)
Status: Not a bug Package: ssh2 (PECL)
PHP Version: 7.4.14 OS: Windows Home
Private report: No CVE-ID: None
 [2021-01-09 18:22 UTC] dev at springtimesoftware dot com
Description:
------------
Environment: PHP 7.4.13 (this value not available in dropdown box)
  Windows 7.4 Thread Safe (TS) x64 package downloaded from https://pecl.php.net/package/ssh2/1.2/windows

In PHP.ini:

[SSH2]
extension=php_ssh2.dll


Test script:
---------------
Script showing problem:

The parameters used in this script have worked in coreFTP, a manual sFTP program, and in PuTTY, a manual SSH program.

====
$c=GetConfigArr("secret.json");
extract($c);

echo "Uploading...".N;

$methods=['kex' => 'diffie-hellman-group1-sha1',
  'client_to_server' => [
    'crypt' => '3des-cbc',
    'comp' => 'none'],
  'server_to_client' => [
    'crypt' => 'aes256-cbc,aes192-cbc,aes128-cbc',
    'comp' => 'none']];

/* Callback if the server terminates the connection */
function on_ssh_disconnect($reason, $message, $language) {
  printf("Server disconnected with reason code [%d] and message: %s\n",
         $reason, $message);
}
$cb=['disconnect' => 'on_ssh_disconnect'];

$conn = ssh2_connect($c['hostDomain'],$c['securePort'],$methods,$cb);
var_export($conn);
exit;
====
Note: also fails if "hostDomain" is changed to "hostIP".


Expected result:
----------------
I expect to be able to connect to the remote (Centos/Apache/cPanel) web server with a returned non-null connection resource.

I expected this script to work, since it was more or less copied from an example in the PHP Manual, but it fails with error message "PHP Warning:  ssh2_auth_password(): Authentication failed for username using password in C:\Dropbox\Private\Web\nsr-HMAC\upload\upload.php on line 29".

Actual result:
--------------
Output:

Uploading...
NULL


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-02-09 17:34 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2021-02-09 17:34 UTC] cmb@php.net
It appears to be unlikely that the given test script failed with
this warning, since ssh2_auth_password() has not been called at
all.
 [2021-02-09 17:58 UTC] dev at springtimesoftware dot com
I agree with the assessment that this report is invalid. I found the documentation of the PHP ssh2 commands to be very difficult to understand. It was only after several weeks of discussions on various fora and mailing lists that I finally found someone who was able to get the ssh2 commands to work and could provide working code examples.

I plan on publishing working examples in several places where I found others, like me, who were unsuccessful in using the ssh2 commands due to the lack of complete working examples showing how to upload a file using the SFTP protocol with an RSA private key, similar to the existing working FTP file upload example, in the PHP Manual.

Sometimes adequate documentation cannot be provided by the original authors of a library due to their being too familiar with their subject matter and not trained in explaining to others who know less.
 [2021-02-09 18:04 UTC] cmb@php.net
-Status: Feedback +Status: Not a bug
 [2021-02-09 18:04 UTC] cmb@php.net
You may consider providing pull requests for the PHP manual[1]
which certainly needs improvement regarding the SSH2 extension.

I think this ticket can be closed.

[1] <https://github.com/php/doc-en/pulls>
 [2021-02-09 18:11 UTC] dev at springtimesoftware dot com
I would like to consider providing pull requests for the PHP manual. I understand what a pull request is in GitHub, but I do not know the location of the PHP Manual repository and I may not have write access to it.
 [2021-02-09 18:12 UTC] dev at springtimesoftware dot com
I apologize for my previous comment, which was stupid. I see no way to delete it.
 [2021-02-09 18:19 UTC] cmb@php.net
There are mirrors of the sources of the PHP manual on Github:

    <https://github.com/php/doc-en/>
    <https://github.com/php/doc-base/>

There are instructions on how to work on the manual on:

    <https://github.com/php/doc-base/#readme>

However, these are currently for those with push access to the
actual Git repos on git.php.net.

You'd basically have to replace the git@git.php.net URIs with the
Github ones when doing the "Source checkout".
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Mar 01 09:01:24 2021 UTC