Why does SFTP via PHP fail, but succeeds in FileZilla on my Windows 8.1 machine?

邮差的信 提交于 2020-01-24 18:46:04

问题


In PHP, I cannot even get the SFTP connection to work. I have tried to use the native SFTP functionality (ssh_connect), and it fails to connect. I have also tried to use phpseclib, but it fails as well. Neither of my aforementioned attempts have provided much in the way of log info.

The native code:

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 library code:

include('Net/SFTP.php');

$sftp = new Net_SFTP('sftp.example.com');
if (!$sftp->login('username', 'password')) {
    exit('Login Failed');
}

I have also tried to track all of the transactions via Fiddler to see if I at least see a connection being made, and I do see an error in the browser (below) that from googling may mean that a connection was made to the server, but no responses.

[Fiddler] ReadResponse() failed: The server did not return a complete response for this request. Server returned 17139 bytes. 

Why am I able to connect to the URL with the username and password via FIleZilla, but not from within php? Do I need some other DLLs in PHP's /ext folder (e.g. php_openssl.dll, etc.)?

Thanks, Sean

来源:https://stackoverflow.com/questions/31363709/why-does-sftp-via-php-fail-but-succeeds-in-filezilla-on-my-windows-8-1-machine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!