dtja73027
2016-02-25 01:43
浏览 42
已采纳

如何使用PHP进行SFTP [重复]

This question already has an answer here:

I'm interested in trying to get SFTP working with the following PHP method: ftp_ssl_connect(host,port,timeout);

I notice that on W3CSchools (http://www.w3schools.com/php/func_ftp_ssl_connect.asp) there is the following note:

Note: This function is only available if both the ftp module and the OpenSSL support is built statically into PHP.

I am left with the question as to how to "build statically" both the "ftp module" and "OpenSSL support" into PHP. I have googled around and there seems to be very sparse information on this subject.

When I currently try to run the code from W3CSchools with legitimate credentials, I constantly get "false" returned. I can successfully SFTP in with the same credentials and port I am using with PHP, so that isn't the problem.

I realize there is another similar question on StackOverflow; however, that question does not even mention nor give an explanation as to how to use the PHP function ftp_ssl_connect() and I would still like to know how to use it and when to use it.

</div>

图片转代码服务由CSDN问答提供 功能建议

此问题已经存在 这里有一个答案:

  • 如何使用PHP进行SFTP? 4 answers < / li>

    我有兴趣尝试让SFTP使用以下PHP方法: ftp_ssl_connect(host,port ,超时);

    我注意到在W3CSchools上( http://www.w3schools.com/php/func_ftp_ssl_connect.asp )有以下注释:

    注意:此功能是 仅当ftp模块和 OpenSSL支持都静态构建到PHP中时才可用。

    我留下了 关于如何“静态”构建“PHP”中的“ftp模块”和“OpenSSL支持”的问题。 我在谷歌上搜索,似乎有关于这个主题的非常稀少的信息。

    当我目前尝试使用合法凭据从W3CSchools运行代码时,我不断返回“false”。 我可以使用与PHP一样的凭据和端口成功进行SFTP,因此这不是问题。

    我意识到有 StackOverflow上的另一个类似问题; 但是,这个问题甚至没有提及也没有解释如何使用PHP函数ftp_ssl_connect(),我仍然想知道如何使用它以及何时使用它。

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • doucheng3811 2016-02-25 01:56
    已采纳

    SFTP (not to be confused with FTPS) is a tool provided by the OpenSSH suite (and other implementations) to securely transfer files over an SSH connection. It is in no way related to FTP or FTPS, which is what the function you're using is for.

    You are probably looking for https://secure.php.net/manual/en/function.ssh2-sftp.php and the other related functions.

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题