php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22946 exec() or system() or passthru() hang when using openssh 3.4
Submitted: 2003-03-28 18:27 UTC Modified: 2005-03-12 00:43 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: massimo at tuxel dot com Assigned:
Status: Not a bug Package: Program Execution
PHP Version: 4.3.1 OS: SuSE Linux 8.1
Private report: No CVE-ID: None
 [2003-03-28 18:27 UTC] massimo at tuxel dot com
Using ssh through the various exec functions usually hangs 
php execution. Very strange that: 
exec('/usr/bin/scp foo@bar.com:/what/ever/file .') 
works fine, while 
exec('/usr/bin/ssh foo@bar.com /what/ever/execfile'), 
where "execfile" is any executable file, makes the 
execution of the php script hang. 
 
Any help/reproduction/confirmation of this very 
appreciated. 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-04-21 09:19 UTC] sniper@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 [2005-03-10 04:24 UTC] ross at rbecker dot org
I am experiencing this same issue on SuSE 9.1 with PHP 4.3.4 and OpenSSH 3.8. This is a more recent PHP than the one you offered up to solve the problem.

I have narrowed it down to exec'ing ssh specifically. I am using passwordless public/private key authentication to a user account with very limited priveledges on the remote host.

The ssh command to the remote host is actually executed, but PHP never comes back.

The problem occurs using system(),shell_exec(), and popen().

I have reproduced this with a script as simple as:

<?php
system("ssh user@host mycommand_with_no_output");
?>
HTML GOES HERE


The result is that PHP never comes back, and it does not error out either.  Executing this via the command line works fine, executing it as a web-script hangs permanently.
 [2005-03-10 04:57 UTC] ross at rbecker dot org
One more note here- 
  I'm aware that there is a PECL extension to add ssh functionality to PHP. I would much prefer NOT to use that extension as it is dependant on a 3rd party library, not actual openssh code, so utilizing this library would create a dependancy on something my vendor does not support or provide bug/security fixes for. I'd much prefer to utilize what exists on the system.
 [2005-03-12 00:43 UTC] rasmus@php.net
scp is non-interactive, so it works fine in batch mode like that.  ssh is interactive and as such requires a controlling tty.  So it would likely work from PHP running in a TTY in CLI mode, but not from Apache since there is no underlying tty for ssh to attach to.  This is in no way a PHP bug.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 03:01:28 2024 UTC