ssh2_exec completely broken

Bug #501959 reported by greenmoss
14
This bug affects 3 people
Affects Status Importance Assigned to Milestone
php-ssh2 (Ubuntu)
New
Undecided
Unassigned

Bug Description

Environment:

$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=9.10
DISTRIB_CODENAME=karmic
DISTRIB_DESCRIPTION="Ubuntu 9.10"

$ dpkg -l libssh2-php
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Cfg-files/Unpacked/Failed-cfg/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Description
+++-=================-=================-==================================================
ii libssh2-php 0.11.0-2 PHP Bindings for libssh2

Problem description:

I have a PHP script which attempts to do some SSH operations on another host. This script was originally running on a Gentoo machine, also version 0.11. It worked fine there, with code such as:

        $ssh_connection = ssh2_connect($ssl_host, 22);
        $stream = ssh2_exec($ssh_connection, "ls /etc/ssl/people/$user");
        stream_set_blocking($stream, true);
        $ssl_files = split("\n", stream_get_contents($stream));

On the Ubuntu host, the PHP script returns inconsistent results: sometimes $ssl_files returns nothing, sometimes a few things, sometimes everything. I get the same inconsistent results when trying several variations: fetch from stream using fread, pass in pty (third argument) as FALSE. At least one other person on the internet is also experiencing this problem:

http://www.frostjedi.com/phpbb/viewtopic.php?f=46&t=13223

Please fix this; this whole package is next to useless unless ssh2_exec works.

Revision history for this message
igorojas (igorojas) wrote :

I am experiencing the same thing here. Is either hit or miss with ssh2_exec on Ubuntu 9.10. Totally useless.

Revision history for this message
v. (tishma) wrote :

Hi,
I've had the same problem for days (ubuntu server 9.10, php 5.2.10-2ubuntu6.4). I just installed 2 packages, and ssh2_exec appears to be working. The packages are:
 - libssh2-1-dbg
 - libssh2-1-dev

You can give it a shot. I couldn't break it so far.

Cheers
v.

Revision history for this message
v. (tishma) wrote :

Sry. My bad.

After more testing, it appears to be breaking again.

The fact that this kind of change increases the chances of successfully reading ssh2_exec standard output might give the idea why this happens to someone in the matter.

 $stream = ssh2_exec($ssh_connection, "ls /etc/ssl/people/$user ; echo > /dev/null"); //now more than 80% stream_get_contents return something

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.