אממממ תנסה לעשות במקום לוקל הוסט אייפי של השרת !
בכל מקרה לא עובד תגיד לי
אם הקוד הזה עובד !
ואני אומר מראש זה לא קוד שלי זכויות למישהו באינטרנט שפעם שלח לי :\
PHP קוד:
// Connection to SSH server
echo "Connexion SSH ";
if (!($resource=@ssh2_connect("192.168.0.1"))) {
echo "[FAILED]<br />";
exit(1);
}
echo "[OK]<br />";
// Authentification by login/passwd
echo "Authentification ";
if (!@ssh2_auth_password($resource,"root","your_password")) {
echo "[FAILED]<br />";
exit(1);
}
echo "[OK]<br />";
// We need a shell
echo "Shell stdio ";
if (!($stdio = @ssh2_shell($resource,"xterm"))) {
echo "[FAILED]<br />";
exit(1);
}
echo "[OK]<br />";
// Execution of any command
// Be careful to add an '\n' at the end of the command
$command = "/bin/ls /tmp\n";
fwrite($stdio,$command);
// IMPORTANT
// For some obscur reasons, just after ur command, u need to make a sleep to be sure, that the command has reached the server and is running
sleep(1);
// Then u can fetch the stream to see what happens on stdio
while($line = fgets($stdio)) {
flush();
echo $line."<br />";
}
// It's always cleaner to close all stream
fclose($stdio);
תמלא איפה שאייפי וכל שאר הפרטים !
בכל מקרה אחרי שעשית שאתה לא מצב בטוח אתה לא חייב ליצור התחברות אחי !