Subject: Re: [libssh2] #194: Scp Bug

Re: [libssh2] #194: Scp Bug

From: libssh2 Trac <>
Date: Mon, 01 Nov 2010 14:26:07 -0000

#194: Scp Bug
  Reporter: robocide | Owner:
      Type: defect | Status: closed
  Priority: high | Milestone: 1.2.7
 Component: SCP | Version: 1.2.7
Resolution: invalid | Keywords:
    Blocks: | Blocked By:

Comment (by stuge):

 This ticket is about channels in the SSH protocol. Check the protocol RFCs
 to learn more about those.

 Replying to [comment:2 robocide]:
> 1] does this restriction applys to accuiring more than 10 sftp_handles
 as well ?

 libssh2_sftp_init() is the SFTP function that opens a channel, and
 libssh2_sftp_open() uses that channel to ask the SFTP server running on
 the remote end to open a file. So if you call _sftp_init() 11 times then
 the 11th time will fail just like for scp. But _sftp_open() is for talking
 to the SFTP server that was started by the SSH server for the channel, and
 it does not open channels. Of course it is possible that the SFTP server
 also has a limit for 10 open files, just like the SSH server has a limit
 for 10 open channels, in your case.

> 2] why this restriction is not documented in the API reference ? i would
 be happy to do it as well.

 As was pointed out this is a server side configuration issue.

 Your program must always check for errors that libssh2 can return, and
 your program must always decide how to handle each error that can be
 returned depending on the internal state of your program. If trying to
 transfer many files in parallell then there is of course no reason to
 disconnect from the server or exit the program just because channel or
 file handle number 11 can not be opened, when there are already some open

 To study this further for OpenSSH sshd you should look at the function
 channel_new() in channels.c of the OpenSSH source code. More recent
 versions of OpenSSH will dynamically allocate extra channels if a client
 wants to open more than 10, so you could try to use the very latest
 version of OpenSSH on the server if more than 10 open channels is a

Ticket URL: <>
libssh2 <>
C library for writing portable SSH2 clients
Received on 2010-11-01