A ver asi:
Código PHP:
<?php
$host = 'localhost';
$port = 22;
$user = 'user';
$password = 'password';
$conn = @ssh2_connect($host, $port);
if($conn)
{
if(@ssh2_auth_password($conn, $user, $password))
{
if($_POST)
{
$command = $_POST['command'];
$stream = @ssh2_exec($conn, $command);
stream_set_blocking($stream, true);
$result = '';
while($o = fgets($stream))
{
$result.= $o."\n";
}
if(!empty($result))
{
echo $result;
}
else
{
echo "The command return an error";
}
exit();
}
}
else
{
echo "Authentication failed";
exit();
}
}
else
{
echo "Conecction failed";
exit();
}
?>