PHP脚本将文件从Web服务器复制到独立mac osx
我正在尝试连接到mac osx。 但是我有错误。 我怎么能把文件复制到这个mac上 此外,我还有以下几点: afp://192.xxx.x.x smb://192.xxx.x.x name@192.xxx.x.x 错误:PHP脚本将文件从Web服务器复制到独立mac osx,php,macos,ssh,Php,Macos,Ssh,我正在尝试连接到mac osx。 但是我有错误。 我怎么能把文件复制到这个mac上 此外,我还有以下几点: afp://192.xxx.x.x smb://192.xxx.x.x name@192.xxx.x.x 错误: if (!function_exists("ssh2_connect")) die("function ssh2_connect doesn't exist"); // log in at server1.example.com on port 22 if(!($con =
if (!function_exists("ssh2_connect")) die("function ssh2_connect doesn't exist");
// log in at server1.example.com on port 22
if(!($con = ssh2_connect("192.xxx.xx.xx", 22))){
echo "fail: unable to establish connection\n";
} else {
// try to authenticate with username root, password secretpassword
if(!ssh2_auth_password($con, "", "")) {
echo "fail: unable to authenticate\n";
} else {
// allright, we're in!
echo "okay: logged in...\n";
// execute a command
if (!($stream = ssh2_exec($con, "ls -al" ))) {
echo 123;
echo "fail: unable to execute command\n";
} else {
// collect returning data from command
stream_set_blocking($stream, true);
$data = "";
while ($buf = fread($stream,4096)) {
$data .= $buf;
}
ssh2_exec($con, 'ls -al; echo "__COMMAND_FINISHED__"' );
fclose($stream);
}
}
}
警告:ssh2_connect():无法连接到端口22上的192.xxx.x.x
在第7行的/home/test.php中
警告:ssh2_connect():无法连接到中的192.xxx.x.x
/第7行的home/test.php失败:无法建立连接
PHP脚本:
if (!function_exists("ssh2_connect")) die("function ssh2_connect doesn't exist");
// log in at server1.example.com on port 22
if(!($con = ssh2_connect("192.xxx.xx.xx", 22))){
echo "fail: unable to establish connection\n";
} else {
// try to authenticate with username root, password secretpassword
if(!ssh2_auth_password($con, "", "")) {
echo "fail: unable to authenticate\n";
} else {
// allright, we're in!
echo "okay: logged in...\n";
// execute a command
if (!($stream = ssh2_exec($con, "ls -al" ))) {
echo 123;
echo "fail: unable to execute command\n";
} else {
// collect returning data from command
stream_set_blocking($stream, true);
$data = "";
while ($buf = fread($stream,4096)) {
$data .= $buf;
}
ssh2_exec($con, 'ls -al; echo "__COMMAND_FINISHED__"' );
fclose($stream);
}
}
}
我们将端口22打开到wright。在您试图连接到的计算机上,端口22似乎没有为入站连接打开。@MarkChorley,如何在mac上启用此功能?或者您没有运行ssh守护程序。谷歌?这不是一个真正的编程问题,可能特定于您的操作系统版本