|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-01-20 11:55 UTC] dimitri dot osler at starsystem dot biz
Description:
------------
I'm using version 0.5 and having problems copying files with the function ssh2_scp_send when the file is large (> 1Mb).
The error reported in auth.log is the following:
sshd[23111]: fatal: buffer_get: trying to get more bytes 8192 than in buffer 8186
Moreover I haven't been able to connect to ssh servers running debian with standard configurations for the sshd daemon.
The error reported in auth.log is the following:
sshd[23019]: fatal: Timeout before authentication for x.x.x.x
Reproduce code:
---------------
<?
$connection = ssh2_connect('127.0.0.1', 22);
if (ssh2_auth_password($connection, 'test', 'xxx')) {
echo "Authentication Successful!\n";
} else {
die('Authentication Failed...');
}
set_time_limit(200);
if (ssh2_scp_send($connection, '/tmp/test', '/home/test/test', 0644)) echo "File Transfered!\n"; ;
?>
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 11:00:01 2025 UTC |
These were both bugs in the underlying libssh2 library. The first resulted from forgetting to update channel window thresholds, the second from expecting to receive a welcome banner before sending one. I've fixed both of these issues in CVS (actually the second was fixed a couple days ago), if you'd like to get a jump on things by patching yourself, the solution to the first issue is: --- src/channel.c 6 Jan 2005 17:32:17 -0000 1.14 +++ src/channel.c 20 Jan 2005 21:22:59 -0000 @@ -902,7 +902,7 @@ libssh2_error(session, LIBSSH2_ERROR_CHANNEL_EOF_SENT, "EOF has already been sight, data might be ignored", 0); } - if (channel->blocking && channel->local.window_size_initial && (channel->local.window_size <= 0)) { + if (channel->blocking && (channel->local.window_size <= 0)) { /* twiddle our thumbs until there's window space available */ if (libssh2_packet_read(session, 1) < 0) { /* Error occured, disconnect? */ @@ -925,7 +925,7 @@ /* Don't exceed the remote end's limits */ /* REMEMBER local means local as the SOURCE of the data */ - if (channel->local.window_size_initial && (buflen > channel->local.window_size)) { + if (buflen > channel->local.window_size) { buflen = channel->local.window_size; } if (buflen > channel->local.packet_size) { Index: src/packet.c =================================================================== RCS file: /cvsroot/libssh2/libssh2/src/packet.c,v retrieving revision 1.10 diff -u -r1.10 packet.c --- src/packet.c 6 Jan 2005 00:51:30 -0000 1.10 +++ src/packet.c 20 Jan 2005 21:22:59 -0000 @@ -475,6 +475,19 @@ return retval; } break; + case SSH_MSG_CHANNEL_WINDOW_ADJUST: + { + LIBSSH2_CHANNEL *channel = libssh2_channel_locate(session, libssh2_ntohu32(data + 1)); + unsigned long bytestoadd = libssh2_ntohu32(data + 5); + + if (channel && bytestoadd) { + channel->local.window_size += bytestoadd; + } + + LIBSSH2_FREE(session, data); + return 0; + } + break; } packet = LIBSSH2_ALLOC(session, sizeof(LIBSSH2_PACKET)); The solution to the second issue is: --- src/session.c 6 Jan 2005 00:51:30 -0000 1.12 +++ src/session.c 18 Jan 2005 19:17:29 -0000 1.13 @@ -254,18 +254,18 @@ session->socket_fd = socket; /* TODO: Liveness check */ - if (libssh2_banner_receive(session)) { - /* Unable to receive banner from remote */ - libssh2_error(session, LIBSSH2_ERROR_BANNER_NONE, "Timeout waiting for banner", 0); - return LIBSSH2_ERROR_BANNER_NONE; - } - if (libssh2_banner_send(session)) { /* Unable to send banner? */ libssh2_error(session, LIBSSH2_ERROR_BANNER_SEND, "Error sending banner to remote host", 0); return LIBSSH2_ERROR_BANNER_SEND; } + if (libssh2_banner_receive(session)) { + /* Unable to receive banner from remote */ + libssh2_error(session, LIBSSH2_ERROR_BANNER_NONE, "Timeout waiting for banner", 0); + return LIBSSH2_ERROR_BANNER_NONE; + } + if (libssh2_kex_exchange(session, 0)) { libssh2_error(session, LIBSSH2_ERROR_KEX_FAILURE, "Unable to exchange encryption keys", 0); return LIBSSH2_ERROR_KEX_FAILURE; Otherwise you can just checkout the current cvs HEAD from sourceforge.net (the second one is in anonymous cvs already, but the first won't be there for a good 3 hours). Failing all those, you'll see these fixes in the next release.