|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72988 ssh2.sftp wrapper does not work with multiple connections correctly
Submitted: 2016-08-31 09:34 UTC Modified: -
From: liborm85 at gmail dot com Assigned:
Status: Closed Package: ssh2 (PECL)
PHP Version: 7.0.10 OS: Debian 8.1
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: liborm85 at gmail dot com
New email:
PHP Version: OS:


 [2016-08-31 09:34 UTC] liborm85 at gmail dot com
If I using wrappers ssh2.sftp on one connection all works correctly.
But if I connected to two servers at one time, both connections works if I using methods ssh2_..., but with ssh2.sftp wrapper works only first connection, second connection return for example this warning:
Warning:  stat(): stat failed for ssh2.sftp://Resource id #14/some/file/that/exists in /test.php on line 19

Not working function stat, file_exists, is_file, etc.

Using PHP 7.0.10, php-ssh2 1.0.

In PHP 5.4 and php-ssh2 0.12 it works fine.

Test script:
function connect($host, $user, $pass) {
  $session = ssh2_connect($host, 22);
  ssh2_auth_password($session, $user, $pass);
  $sftp = ssh2_sftp($session);
  return $sftp;

// first connection
$sftp1 = connect("", "user", "password");
$path1 = "/some/file/that/exists";
$stat1 = stat("ssh2.sftp://$sftp1" . $path1); // works
var_dump($stat1 === false ? 'ERROR' : 'OK');
$sshstat1 = ssh2_sftp_stat($sftp1, $path1); // works
var_dump($sshstat1 === false ? 'ERROR' : 'OK');

// second connection to another server
$sftp2 = connect("", "user", "password");
$path2 = "/some/file/that/exists";
$stat2 = stat("ssh2.sftp://$sftp2" . $path2); // doesn't work
var_dump($stat2 === false ? 'ERROR' : 'OK');
$sshstat2 = ssh2_sftp_stat($sftp2, $path2); // works
var_dump($sshstat2 === false ? 'ERROR' : 'OK');

Expected result:
string(2) "OK"
string(2) "OK"
string(2) "OK"
string(2) "OK"

Actual result:
string(2) "OK"
string(2) "OK"
<br />
<b>Warning</b>:  stat(): stat failed for ssh2.sftp://Resource id #14/some/file/that/exists in <b>/test.php</b> on line <b>19</b><br />
string(5) "ERROR"
string(2) "OK"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-09-27 03:15 UTC]
Automatic comment on behalf of
Log: bugfix #72988
 [2016-09-27 03:15 UTC]
-Status: Open +Status: Closed
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Jul 23 03:01:28 2024 UTC