php - 使用 sftp 和 ssh2 的 fopen 段错误

标签 php amazon-web-services ssh segmentation-fault sftp

我有一个在 AWS 上运行的 php 系统和一个使用 shh2sftp 在外部服务器上上传 xlsx 文件的类。 此代码在上次升级 aws 包 openssh-clients-6.6.1p1-31.62openssh-server-6.6.1p1-31.62 之前一直运行良好,此时我有一个 <fopen 期间出现 strong>segfault。 Fopen 在外部服务器上创建一个文件。 这里的代码:

$stream = @fopen("ssh2.sftp://$this->sftp$remote_file", 'w');

然后我使用 $stream 来编写内容,但是代码停止在 fopen 上,因为出现了段错误。 我没有找到关于这个问题的任何信息,我认为问题是 opnessh 的新升级,因为 php 代码没有改变。 有什么想法吗?

最佳答案

在 StackOverflow 上找到答案: https://stackoverflow.com/a/40972584/2520795

似乎自从这次 PHP 更新后,您必须用 intval() 包围您的主机部分(ssh2_sftp() 的结果):

$handle = opendir("ssh2.sftp://".intval($sftp)."/path/to/directory");

在我的例子中,有一个 fopen 而不是 opendir,但解决方案是一样的。

关于php - 使用 sftp 和 ssh2 的 fopen 段错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41118475/

相关文章:

PHP - 优化查找数组中的最近点

PHP 将 ISO 日期转换为更易读的格式?

Erlang、SSH 和authorized_keys

git - 如何在heroku中重置我的私钥?

linux - 请调试 SSH 代理命令,它无法在 PuTTY 上使用多跳 SSH 连接远程服务器

php - 不允许 > 2mb 的图像

php - 在 PHP 中,对象方法代码是否在实例之间重复或共享?

python - Django 在部署到 Elastic Beanstalk 时看不到环境变量

amazon-web-services - 提供的请求无效:AWS::ElasticLoadBalancingV2::ListenerRule 验证异常

ios - iOS 的 AWS Cognito SMS 传输问题