In addition to the last post (13 years ago) from Dennis K. I corrected two typos (constant SSH2_STREAM_STDIO was misspellt) and removed (too many) brackets - this code works:<?php $stdout_stream = ssh2_exec($connection, "lsssss -la"); $sio_stream = ssh2_fetch_stream($stdout_stream, SSH2_STREAM_STDIO); $err_stream = ssh2_fetch_stream($stdout_stream, SSH2_STREAM_STDERR); stream_set_blocking($sio_stream, true); stream_set_blocking($err_stream, true); $result_dio = stream_get_contents($sio_stream); $result_err = stream_get_contents($err_stream); echo 'stderr: ' . $result_err; echo 'stdio : ' . $result_dio;?>