php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58893 Unable to request a channel from remote host
Submitted: 2009-10-13 14:29 UTC Modified: 2015-07-15 13:43 UTC
Votes:5
Avg. Score:4.6 ± 0.8
Reproduced:4 of 4 (100.0%)
Same Version:1 (25.0%)
Same OS:2 (50.0%)
From: post at rolandgruber dot de Assigned: langemeijer (profile)
Status: Closed Package: ssh2 (PECL)
PHP Version: 5.3.0RC4 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: post at rolandgruber dot de
New email:
PHP Version: OS:

 

 [2009-10-13 14:29 UTC] post at rolandgruber dot de
Description:
------------
Hi,

I am the developer of LDAP Account Manager. One of our users reported that he gets the following message when multiple ssh2_exec() commands are executed:

Warning: ssh2_exec() [function.ssh2-exec]: Unable to request a channel from remote host

He tried compiling the last versions of libssh2 and php-ssh2 without success. The error occurs at the second call of ssh2_exec().

Any ideas?


Best regards

Roland


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-10-22 15:01 UTC] cx4net at hotmail dot com
I'm confirming this problem.

In fact, the problem appears when using stream_set_blocking ($stream, false).

so if you do something like :

$stream = ssh2_exec ($res, 'ls -l');
stream_set_blocking ($stream, false);
while ($line = fgets ($stream)) {
    echo $line;
}

the other calls to ssh2_exec will fail with this error.
I can't find where the problem could be but it a bug for sure.

If you using stream_set_blocking ($stream, true), you can call multiple ssh2_exec ();

Maybe the ssh connexion is closed or lost when using stream_set_blocking ($stream, false) ?

Thanks for your help !
 [2009-10-25 07:16 UTC] post at rolandgruber dot de
We tried setting the stream blocking to true but this did not help. Looks like the problem is located deeper.
 [2010-01-21 06:32 UTC] miles at milestails dot com
Hi,

I've also noticed this problem and there doesn't appear to be any work around at the moment apart from reverting back to libssh2 0.13. However this is a very old library and contains other bugs which inhibit development.

The PECL ext really needs revising to comply with the libssh2 1.2+ library.

Regards,

Miles
 [2010-04-21 08:40 UTC] mehturt at gmail dot com
I hit the same problem on Solaris 10 with libssh2 1.1, but it seems to be fine with libssh2 1.2.4.
 [2010-11-15 17:31 UTC] jl_ewing at hotmail dot com
Seeing the same error.

Tried php 5.3.3 and ssh2-0.11.0 combined with libssh2-1.2.6 and libssh2-1.2.7 with no luck.  Now going to try php 5.3.3 with ssh2-0.11.2 with libssh2-1.2.7.  If that doesn't work going to try libssh2-1.2.4.
 [2010-11-15 17:45 UTC] pierre dot php at gmail dot com
Simply try with the latest libssh2 version please.

The PHP binding does nothing but to read local data and other simple tasks. All the SSH2 implementation is part of libssh2.
 [2010-11-15 18:23 UTC] jl_ewing at hotmail dot com
libssh2-1.2.7 is the latest on the http://www.libssh2.org/ website.  When used with php 5.3.3 & PECL/ssh2-0.11.2 the first call to ssh2_exec with stream_set_blocking ($stream, false) works but upon trying to call ssh2_exec again it spits up

PHP Warning:  ssh2_exec(): Unable to request a channel from remote host in /opt/tool/sshtest.php on line 26

if stream_set_blocking is true it operates fine.
 [2010-11-18 19:34 UTC] justin_masterson at yahoo dot com
I am willing to pay to have this fixed.  The only workaround we have found is to establish a SSH connection EVERY time you need to exec which adds overhead to both sides of the connection.
 [2010-11-18 19:51 UTC] pierre dot php at gmail dot com
@miles at milestails dot com

"The PECL ext really needs revising to comply with the libssh2 1.2+ library."

for example?
 [2010-11-18 20:35 UTC] pierre dot php at gmail dot com
I just took the hand over the ssh2 extension so I'm catching up with the bugs (some of them could be in libssh2).

I'm not sure yet how to make the ssh2 stream non blocking after having opening it. It could be tricky. More later in the next 2 weeks (or if one of you have an idea :)
 [2010-11-18 21:07 UTC] jl_ewing at hotmail dot com
I'm not even sure if stream_set_blocking is the right place to set the blocking consider libssh2 has a 

void libssh2_session_set_blocking(LIBSSH2_SESSION *session, int blocking); 

But then again I thought the stream functions were supposed to be generic for any stream.  Of course if we're calling stream_set_blocking on the ssh2 stream and if it's not aware of what libssh2 expects, maybe that's where the issues.

Of course I am not a C programmer either... maybe I just need to shut my mouth... or learn C...

Of course there is a feature request in the libssh2 queue that I would REALLY like (public key auth from memory - e.g. passed as a variable maybe?)
 [2012-06-15 12:43 UTC] langemeijer@php.net
-Status: Feedback +Status: Open
 [2012-06-20 15:19 UTC] langemeijer@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: langemeijer
 [2012-06-20 15:19 UTC] langemeijer@php.net
Closing the issue. Cannot reproduce with recent libssh2 version. Probably solved 
somewhere before 1.2.4.

jl_ewing: stream_set_blocking() calls libssh2_session_set_blocking() for ssh2 
streams.
 [2013-04-04 03:02 UTC] ian dot schorr at emc dot com
I'm still seeing this with libssh2 1.4.3 and ssh2 package 0.12.
 [2013-04-04 03:17 UTC] ian dot schorr at gmail dot com
And as before, the problem does not occur if set_stream_blocking is true.
 [2013-04-04 09:46 UTC] langemeijer@php.net
-Status: Closed +Status: Re-Opened -Assigned To: langemeijer +Assigned To:
 [2013-05-07 12:39 UTC] wojbach at gmail dot com
I recommend for anyone to wrap ssh2 function in a class that uses FABRIC design pattern.
 [2014-06-23 09:22 UTC] gavinstaniforth at wems dot co dot uk
With stream_set_blocking($stream,true); this issue is occurring on with the versions listed below. 

libssh2 Version: 0.18
PHP Version: 5.3.3
 [2015-07-15 13:43 UTC] langemeijer@php.net
-Status: Re-Opened +Status: Closed -Assigned To: +Assigned To: langemeijer
 [2015-07-15 13:43 UTC] langemeijer@php.net
Fixed in git
 [2018-11-15 04:10 UTC] stuff at dumporama dot com
I'm also having this problem.

libssh2/1.8.0
PECL ssh2 1.1.2
PHP 7.1.3
 - on a windows apache server

Using Herzult's php-ssh library from github. First run() is successful but any consecutive run() results in "Warning: ssh2_exec(): Unable to request a channel from remote host"

I can't send any more than one command per-session. It works if I create a new session for every command but that defeats the purpose of the script for me. I'm trying to use it for Cisco routers and that requires entering various commands before the command you want to run, so they have to be entered into the same session.

Curiously.. I'm also having problems with phpseclib but it's not the same error so probably just coincidental. The buffer intermittently returns no data, expected sentences sometimes cut off mid-way.
EG: If I write() the command "show run interface gig1/0/10" a var_dump of the buffer shows just "show ru". That only intermittently, 9/10 times it works just fine.

Either way, it's off to Python for me as these libraries are giving me more grief than desired! :)
 [2019-07-10 20:23 UTC] gavnor at hotmail dot com
libssh2/1.8.0
PECL ssh2 1.1.2
PHP 7.2.9
 - on a windows apache server

First run() is successful but any consecutive run() results in "Warning: ssh2_exec(): Unable to request a channel from remote host"

I can't send any more than one command per-session. It works if I create a new session for every command but that defeats the purpose of the script for me. I'm trying to use it for Cisco routers.

I'm also having problems with phpseclib "Unable to open channel" for subsequent commands while the first one still works.
 [2023-03-30 10:11 UTC] ahmed_salatin2008 at yahoo dot com
atwar-sa.com

اطوار للخدمات المنزلية والمقاولات العامة
كشف تسربات المياه 
عوازل مائية وحرارية
عزل خزانات ارضية وعلوية 
معلم بلاط
 [2023-03-30 10:15 UTC] atwarco340 at gmail dot com
www.atwar-sa.com
كشف تسربات المياه
شركة عزل خزانات بالرياض
معلم بلاط بالرياض
شركة عزل اسطح بالرياض

شركة كشف تسربات بالرياض
 [2023-03-30 10:16 UTC] atwarco340 at gmail dot com
www.atwar-sa.com
كشف تسربات المياه
شركة عزل خزانات بالرياض
معلم بلاط بالرياض
شركة عزل اسطح بالرياض

شركة كشف تسربات بالرياض
www.atwar-sa.com/2020/12/30/%d8%b4%d8%b1%d9%83%d8%a9-%d9%83%d8%b4%d9%81-%d8%aa%d8%b3%d8%b1%d8%a8%d8%a7%d8%aa-%d8%a8%d8%a7%d9%84%d8%b1%d9%8a%d8%a7%d8%b6/
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 09:01:26 2024 UTC