PHP脚本将文件从Web服务器复制到独立的mac-osx


PHP script copy file from webserver to standalone mac osx

我正在尝试连接到mac-osx。但是我犯了错误。我怎么能把文件复制到这个mac上?

此外,我有以下内容:

afp://192.xxx.x.x

smb://192.xxx.x.x

name@192.xxx.x.x

错误:

警告:ssh2_connect():无法连接到端口22上的192.xxx.x.xin/home/test.php在线7

警告:ssh2_connect():无法连接到中的192.xxx.x.x/home/test.php在第7行失败:无法建立连接

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);
    }
}
}

我们向wright打开端口22。