0

我已经在新服务器上上传了我的本地代码。服务器是带有 PHP 5.6.31 和 PHP 5.5.28 的 Centos 7。

我在我的两个 php 版本上都安装了 ssh2 连接库。我正在尝试使用以下代码连接到其他服务器,

if (!function_exists("ssh2_connect"))
    die('Function ssh2_connect not found, you cannot use ssh2 here');
if (!$connection = ssh2_connect($schema['conn']['host'], $schema['conn']['port']))
    die('Unable to connect');
if (!ssh2_auth_password($schema['conn']['connection'], $schema['conn']['username'], $schema['conn']['password']))
    die('Unable to authenticate.');
if (!$stream = ssh2_sftp($schema['conn']['connection']))
    die('Unable to create a stream.');
if (!$dir = opendir('ssh2.sftp://'.intval($stream).$remoteDirPath))
    die('Could not open the directory');

我的代码运行良好,直到

  if (!$stream = ssh2_sftp($schema['conn']['connection']))
    die('Unable to create a stream.');

之后我收到“无法打开目录”错误。这段代码在我的本地运行良好。

谁能帮我解决这个问题?如果需要任何进一步的信息,请告诉我。

4

0 回答 0