|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 07:00:01 2025 UTC |
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) }