1

I'm failing to display the output of an SSH stream in PHP. This is my code:

$output = ssh2_exec($sshCon, $sshCommand);

stream_set_blocking($output, true);

echo stream_get_contents($output);

The output is blank. The command is definitely running though. I also tried the solution given here: Empty PHP SSH2 stream contents, even with stream_set_blocking?

The output should be process ID, just to let you know.

Thanks!

Community
  • 1
  • 1
Prash
  • 1,915
  • 3
  • 20
  • 32

1 Answers1

1

Try phpseclib, a pure PHP SSH implementation:

<?php
include('Net/SSH2.php');

$ssh = new Net_SSH2('www.domain.tld');
if (!$ssh->login('username', 'password')) {
    exit('Login Failed');
}

echo $ssh->exec($sshCommand);
?>
neubert
  • 15,947
  • 24
  • 120
  • 212