- 论坛徽章:
- 1
|
原帖由 chinaunixzcx 于 2009-9-7 22:56 发表 ![]()
流程很简单
$connect=ssh2_connect("192.168.1.2",22);
ssh2_auth_password($connect,user,pass);
$stream=ssh2_exec($connect, "ls /home");
stream_set_blocking($stream, true);
$output = stream_get_ ...
<?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 秒) - 正常终止 |
|