php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73744 ssh2.sftp fopen work with php 7.0.6 ,but not work with 7.0.14.
Submitted: 2016-12-15 04:22 UTC Modified: -
Votes:12
Avg. Score:4.5 ± 0.5
Reproduced:11 of 11 (100.0%)
Same Version:9 (81.8%)
Same OS:5 (45.5%)
From: xiaqii at gmail dot com Assigned:
Status: Open Package: ssh2 (PECL)
PHP Version: 7.0.14 OS: ubuntu 14.04
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2016-12-15 04:22 UTC] xiaqii at gmail dot com
Description:
------------
this script can work with php 7.0.6 ,but not work with 7.0.14.
my script has run with 7.0.6 for months,when i upgrade to 7.0.14,this script didn't work.
script not change.
os not change.
pecl ssh2 1.0 not change.

Test script:
---------------
$conn=ssh2_connect($host, $port);
ssh2_auth_password($conn, $username, $password);
$sftp = ssh2_sftp($conn);
$remote_file="/test.txt";
$stream = fopen("ssh2.sftp://{$sftp}{$remote_file}", 'w');

$stream got false with php7.0.14, absolute or relative path both not work.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-01-09 13:51 UTC] andreausu+php at gmail dot com
We're having the same issue, it appeared when we upgraded from php 7.0.11 to php 7.0.14
 [2017-01-10 18:26 UTC] oldbucsfan at hotmail dot com
Same problem on Windows Server 2012 R2 and PHP 7.1.0 and 7.0.14. I did find a workaround for now if all you want is to download a file.
------------------
$filename = "/folder/filename.pdf";

$connection = ssh2_connect('server.com', 22);
ssh2_auth_password($connection, 'username', 'password');

$tempfilename = tempnam("C:/downloads/", "tmp");
$filetransfered = ssh2_scp_recv($connection, $filename, $tempfilename);

if($filetransfered)
{
  fopen($tempfilename,'r');
}
...

You may also be able to modify that file, then use ssh2_scp_send() to reupload it, changing the file you were attempting to have write access to.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri Aug 23 04:01:26 2019 UTC