|  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
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
Environment: PHP 7.4.13 (this value not available in dropdown box)
  Windows 7.4 Thread Safe (TS) x64 package downloaded from

In PHP.ini:


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.


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);
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:



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-02-09 17:34 UTC]
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2021-02-09 17:34 UTC]
It appears to be unlikely that the given test script failed with
this warning, since ssh2_auth_password() has not been called at
 [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]
-Status: Feedback +Status: Not a bug
 [2021-02-09 18:04 UTC]
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] <>
 [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]
There are mirrors of the sources of the PHP manual on Github:


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


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

You'd basically have to replace the URIs with the
Github ones when doing the "Source checkout".
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 13 05:01:28 2024 UTC