|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73924 ssh2_sftp wrapper issue
Submitted: 2017-01-12 23:33 UTC Modified: -
Avg. Score:4.3 ± 0.9
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: ziggi at ziggi dot pl Assigned:
Status: Open Package: ssh2 (PECL)
PHP Version: 7.1.0 OS: Windows 10 x64
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: ziggi at ziggi dot pl
New email:
PHP Version: OS:


 [2017-01-12 23:33 UTC] ziggi at ziggi dot pl
'php_ssh2-1.0-7.1-nts-vc14-x64' is erratic compared with 'php_ssh2-1.0-7.0-nts-vc14-x64'.

At least this is working wrong in case of the PHP 7.1 release:

is_dir('ssh2.sftp://' . ssh2_sftp(ssh2_connect($host, $port)) . '$absolute_path_to_remote_directory')


In case of a valid folder with appropriate permissions:

php_ssh2-1.0-7.0-nts-vc14-x64 returns 'true' while
php_ssh2-1.0-7.1-nts-vc14-x64 returns' false'

This has been found while using PHPLOY ( on my Windows 10 x64 Pro system using PHP 7.0 (NTS) x64 and PHP 7.1 (NTS) x64 - both VS14 compliations.

Test script:
is_dir('ssh2.sftp://' . ssh2_sftp(ssh2_connect($host, $port)) . '$absolute_path_to_remote_directory');


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-02-27 14:05 UTC] andreas dot krause at webular dot de
Exakt same Issue with PHP 7.1.2 (SSH-2.0-libssh2_1.4.2)

Worked fine with php 5.6.23 (SSH-2.0-libssh2_1.4.2)

System is a Debian 7

my workaround is:

$streamCheck = ssh2_exec($this->getSshConnection(), 'test -d '.escapeshellarg($folder).' && echo 1 || echo 0');
stream_set_blocking($streamCheck, true);
$streamCheck_out = ssh2_fetch_stream($streamCheck, SSH2_STREAM_STDIO);

before it was: is_dir('ssh2.sftp://'.$this->getSftpConnection().$folder) -> this returns now always false
 [2019-02-07 21:49 UTC] memso at memso dot net
You must use intval on the result from ssh2_sftp now, per

So instead, use this:
$ssh2 = ssh2_connect($host, $port);
$sftp = ssh2_sftp($ssh2);
is_dir('ssh2.sftp://' . intval($sftp) . $absolute_path_to_remote_directory)
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Tue Jun 02 19:01:26 2020 UTC