<?php
$connection = ssh2_connect('127.0.0.1',22);
$login = $_GET["login"];
$password = $_GET["password"];
if ( (strlen($login) == 0) || (strlen($password) == 0) ){
die('Please specify login and password!');
}
if (!ssh2_auth_password($connection, $login, $password)) {
die('Unable to authenticate');
}
else {
$str = 'echo ' . $password . '|sudo -S poweroff';
// str_replace is used to escape " characters in the password
$str = str_replace("\"", "\\\"", $str);
$stream = ssh2_exec($connection, $str);
$errorstream = ssh2_fetch_stream($stream, SSH2_STREAM_STDERR);
// enable blocking for both streams
stream_set_blocking($errorstream, true);
stream_set_blocking($stream, true);
echo stream_get_contents($stream);
echo "<br>";
echo stream_get_contents($errorstream);
echo "<br>";
echo "shutting down...";
}
?>
Kitor a écrit:Bonjour,
Et pour un reboot
Utilisateurs parcourant ce forum : Aucun utilisateur inscrit et 4 invité(s)