$connection=ssh2_connect('localhost');
if(!$connection) die('Connection failed');
if(!ssh2_auth_password($connection,'username','password')) die('Login failed');
$stream=ssh2_exec($connection,'ls /tmp');
stream_set_blocking($stream,true);
echo stream_get_contents($stream);