使用ssh2 執行遠程機器命令 獲取執行結果


 

<?php
$connect=ssh2_connect("www.superserver.com",22);
ssh2_auth_password($connect,'HonestQiao','123456');
$stream=ssh2_exec($connect, "cd /usr;ls;");
stream_set_blocking($stream, true);
$output = stream_get_contents($stream);
fclose($stream);
echo $output ;
?>

結果如下:
---------- PHP5 代碼調試 ----------
bin
compat
db
games
home
include
lib
libdata
libexec
local
obj
ports
sbin
share
src

輸出完成 (耗時 3 秒) - 正常終止


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM