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!

1 Answer 1

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);
?>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.