在 PHP 中,我什至无法让 SFTP 连接正常工作。我尝试使用本机 SFTP 功能 (ssh_connect),但无法连接。我也尝试过使用 phpseclib,但它也失败了。我上述的尝试都没有提供太多的日志信息。
本机代码:
if (!function_exists('ssh2_connect')) {
echo "dll not loaded properly"; //never see this, so I know it works
return false;
}
$connection = ssh2_connect('sftp.example.com', 22);
ssh2_auth_password($connection, 'username', 'password');
$sftp = ssh2_sftp($connection);
phpseclib 库代码:
include('Net/SFTP.php');
$sftp = new Net_SFTP('sftp.example.com');
if (!$sftp->login('username', 'password')) {
exit('Login Failed');
}
我还尝试通过 Fiddler 跟踪所有事务,以查看是否至少看到正在建立连接,并且我确实在浏览器中看到错误(如下),来自谷歌搜索可能意味着与服务器建立了连接,但没有回应。
[Fiddler] ReadResponse() failed: The server did not return a complete response for this request. Server returned 17139 bytes.
为什么我可以通过 FIleZilla 使用用户名和密码连接到 URL,但不能从 php 中连接?我是否需要 PHP 的 /ext 文件夹中的一些其他 DLL(例如 php_openssl.dll 等)?
谢谢,肖恩