$connection = ssh2_connect('localhost', 22);
ssh2_auth_password($connection, 'root', '0000000');
$stream = ssh2_exec($connection, 'top');
stream_set_blocking($stream, true);
$stream_out = ssh2_fetch_stream($stream, SSH2_STREAM_STDIO);
print_r( stream_get_contents($stream_out));