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: 2021-02-10 12:17 UTC
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: cmb (profile)
Status: Closed Package: ssh2 (PECL)
PHP Version: 7.0.14 OS: ubuntu 14.04
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: xiaqii at gmail dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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.
 [2021-02-10 12:17 UTC] cmb@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2021-02-10 12:17 UTC] cmb@php.net
This problem has been introduced with PHP 7.0.13, and is fixed as
of ssh2 1.1.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Nov 09 09:01:28 2024 UTC