2016-01-06 35 views
0

我正在嘗試連接到mac osx。 但我收到錯誤。 如何在世界上我可以複製文件到這個mac?PHP腳本從網絡服務器複製文件到獨立的mac osx

此外,我有以下幾點:

法新社://192.xxx.xx

SMB://192.xxx.xx

[email protected]

錯誤:

警告:ssh2_connect():無法連接到192.xxx.xx上PO室溫22 在上線/home/test.php 7

警告:ssh2_connect():無法連接在 /home/test.php第7行到192.xxx.xx失敗:無法建立連接

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

看起來像端口22未打開您嘗試連接到的計算機上的入站連接。 –

+0

@MarkChorley,我如何在Mac上啓用此功能? – Bas

+0

或者你沒有運行ssh守護進程。去谷歌上查詢?這不是一個真正的編程問題,可能是特定於您的操作系統版本 –

回答

0

我們打開端口22萊特。

相關問題