Prueba ese Script, a mi me ha funcionado de Linux a Linux y manejas los eventos
Código PHP:
Ver original<?php
// log in at server on port 22
echo "fail: unable to establish connection\n";
} else {
// try to authenticate with username root, password secretpassword
echo "fail: unable to authenticate\n";
} else {
// allright, we're in!
echo "okay: logged in...\n";
// execute a command
if(!($stream = ssh2_exec($con, "ls -al" )) ){
echo "fail: unable to execute command\n";
} else{
// collect returning data from command
echo "Executed ls -la\n";
$data = "";
while( $buf = fread($stream,4096) ){
$data .= $buf;
echo "".$buf;
}
}
}
}
?>