尝试使用 ssh2 连接 sftp 服务器,但脚本永远运行,没有任何错误
我尝试使用 ssh2 连接到 sftp 服务器,但 php 似乎陷入了循环。 错误报告已开启。
我的代码:
$connection = ssh2_connect('my-server.url', 22);
var_dump($connection);
if (ssh2_auth_password($connection, 'username', 'password'))
{
echo "Authentication success";
if( ssh2_scp_recv($connection, "/throw_me_an_error/", "/somewhere/" ) )
{
echo "file recived";
}
else
{
echo "error";
}
}
else
{
echo "Authentication failure";
}
生成此输出:
resource(7) of type (SSH2 Session)
Authentication success
但是,一旦脚本尝试运行 ssh2_scp_recv,它就会卡住并永远运行,不会出现任何故障。我尝试使用现有和不存在的文件。每次都是相同的结果 - 脚本循环运行。
这不仅仅是 ssh2_scp_recv 即使我尝试 ssh2_exec 或其他需要在服务器上写入或读取的方法,它也会被卡住。
这是怎么回事?
谢谢!
I try to connect to an sftp server using ssh2 but it seems that php get stuck in a loop.
Error reporting is on.
my code:
$connection = ssh2_connect('my-server.url', 22);
var_dump($connection);
if (ssh2_auth_password($connection, 'username', 'password'))
{
echo "Authentication success";
if( ssh2_scp_recv($connection, "/throw_me_an_error/", "/somewhere/" ) )
{
echo "file recived";
}
else
{
echo "error";
}
}
else
{
echo "Authentication failure";
}
generate this output:
resource(7) of type (SSH2 Session)
Authentication success
But as soon as the script tries to run ssh2_scp_recv it got stucked and runs forever without any failure. I tried it with existing and with non existing files. Every time the same result - the script runs in a loop.
It is not only ssh2_scp_recv even if i try ssh2_exec or some other method whichs need to write or read on the server, it will get stucked.
Whats going on here?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能会更幸运地使用 phpseclib,一个纯 PHP SSH 实现。
You might have more luck with phpseclib, a pure PHP SSH implementation.