php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57694 Failed key auth attempt causes ssh2_scp_send() transfers to fail
Submitted: 2007-06-06 09:31 UTC Modified: 2012-10-06 09:20 UTC
From: davisd50 at yahoo dot com Assigned:
Status: No Feedback Package: ssh2 (PECL)
PHP Version: 5.1.6 OS: Solaris 8
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
40 - 14 = ?
Subscribe to this entry?

 
 [2007-06-06 09:31 UTC] davisd50 at yahoo dot com
Description:
------------
I have code that loops through a list of hosts.

  - The code will attempt key authentication to each host.
  - If key authentication fails, then it will attempt password authentication.
  - On hosts where key authentication is successful, sftp works OK
  - On hosts where key authentication fails, but password authentication is successful, ssh2_scp_send() has problems.
  - This example attempt to transfer the local /.ssh/known_hosts file to remote hosts.  The remote hosts already have a outdated local copy of this file that will be over-written during this process.

Reproduce code:
---------------
$HOST_LIST["192.168.1.1"] = "host1";
$HOST_LIST["192.168.1.2"] = "host2";
foreach ($HOST_LIST as $HOST => $NAME) {
    $conn = ssh2_connect($HOST);
    if (!ssh2_auth_pubkey_file(
                               $conn,
                               "root",
                               "/.ssh/id_rsa.pub",
                               "/.ssh/id_rsa")) {
        ssh2_auth_password($conn, "root", "passwd");
    }
    $sftp = ssh2_sftp($conn);
    // This call to ssh2_scp_send() does not report an
    // error, but also does not transfer the file.
    ssh2_scp_send($conn, 
                  $KNOWN_HOSTS,
                  "/.ssh/known_hosts", 
                  0644)
}

Expected result:
----------------
I expect the remote /.ssh/known_hosts file to be the same as the local /.ssh/knwon_hosts file.

Actual result:
--------------
The remote files are unchanged for hosts where ssh2_auth_pubkey_file() failed and ssh2_auth_password() succeeded.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-06-06 09:34 UTC] davisd50 at yahoo dot com
updated code:

$HOST_LIST["192.168.1.1"] = "host1";
$HOST_LIST["192.168.1.2"] = "host2";
foreach ($HOST_LIST as $HOST => $NAME) {
    $conn = ssh2_connect($HOST);
    if (!ssh2_auth_pubkey_file(
                               $conn,
                               "root",
                               "/.ssh/id_rsa.pub",
                               "/.ssh/id_rsa")) {
        ssh2_auth_password($conn, "root", "passwd");
    }
    $sftp = ssh2_sftp($conn);
    // This call to ssh2_scp_send() does not report an
    // error, but also does not transfer the file.
    ssh2_scp_send($conn, 
                  "/.ssh/known_hosts",
                  "/.ssh/known_hosts", 
                  0644)
}
 [2012-06-14 21:30 UTC] langemeijer@php.net
It's been a while. Can you confirm that this bug still exists with new versions 
of libssh2 and the ssh2 extension?
 [2012-06-14 21:30 UTC] langemeijer@php.net
-Status: Open +Status: Feedback
 [2012-10-06 09:20 UTC] langemeijer@php.net
-Status: Feedback +Status: No Feedback
 [2012-10-06 09:20 UTC] langemeijer@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 09:01:28 2024 UTC