php - 警告 : ssh2_connect(): Failed overriding server to client COMP method

标签 php ssh compression

我在为 PHP 中的 SSH session 启用压缩时遇到问题。

部分代码:

    $methods = array(
    'server_to_client' => array(
        'comp' => 'zlib')
    );if(!($con = ssh2_connect("10.214.201.31", 22, $methods))){
    ...

执行期间的警告(通过 httpd 或 php cli):

Warning: ssh2_connect(): Failed overriding server to client COMP method

压缩不起作用(通过 ssh2_scp_recv 下载测试文件的时间没有改变)。设置客户端到服务器压缩后出现类似警告。

PHP Version 5.5.15 (latest Xampp for Windows)
ZLib Version    1.2.7
libSSH Version  libssh2/1.4.3

服务器支持 ssh 压缩(WinSCP 下载速度提高 5 倍)。

在 php 或 httpd 的日志中找不到任何其他信息。

我应该如何调查这个问题?

最佳答案

这可能是编译 libssh php5 的版本问题。在我的桌面上试过这个,遇到了同样的问题。

> ssh -C -vv root@host.com
...
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: kex_parse_kexinit: diffie-hellman-group14-sha1
debug2: kex_parse_kexinit: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-rsa-cert-v01@openssh.com,ssh-dss-cert-v01@openssh.com,ssh-rsa-cert-v00@openssh.com,ssh-dss-cert-v00@openssh.com,ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: aes128-ctr,aes256-ctr,arcfour256,arcfour
debug2: kex_parse_kexinit: aes128-ctr,aes256-ctr,arcfour256,arcfour
debug2: kex_parse_kexinit: hmac-sha1,hmac-sha1-96,hmac-md5,hmac-md5-96
debug2: kex_parse_kexinit: hmac-sha1,hmac-sha1-96,hmac-md5,hmac-md5-96
debug2: kex_parse_kexinit: zlib@openssh.com,zlib,none
debug2: kex_parse_kexinit: zlib@openssh.com,zlib,none
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: first_kex_follows 0 
debug2: kex_parse_kexinit: reserved 0 
debug2: kex_parse_kexinit: ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,arcfour
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,arcfour
debug2: kex_parse_kexinit: hmac-sha1,hmac-sha1-96
debug2: kex_parse_kexinit: hmac-sha1,hmac-sha1-96
debug2: kex_parse_kexinit: none,zlib@openssh.com
debug2: kex_parse_kexinit: none,zlib@openssh.com
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: first_kex_follows 0 
debug2: kex_parse_kexinit: reserved 0 
debug2: mac_setup: found hmac-sha1
debug1: kex: server->client aes128-ctr hmac-sha1 zlib@openssh.com
debug2: mac_setup: found hmac-sha1
debug1: kex: client->server aes128-ctr hmac-sha1 zlib@openssh.com

可以看到我的客户端支持zlib@openssh.comzlibnone压缩方式,而服务端只支持zlib@openssh.comnone,因此 key 交换过程最终决定使用 zlib@openssh.com

不幸的是,支持压缩类型zlib@openssh.com wasn't added to libssh2 until 1.4.3是的,你猜对了,我的 php5.4 是用 libssh 1.2.7 编译的。

> phpinfo(INFO_MODULES);
....
ssh2

SSH2 support => enabled
extension version => 0.11.3-dev
libssh2 version => 1.2.7
banner => SSH-2.0-libssh2_1.2.7
remote forwarding => enabled
hostbased auth => enabled
polling support => enabled
publickey subsystem => enabled

TL;DR:如果 WinSCP 使用 zlib@openssh.com 作为压缩,请确保您的 php 是针对 libssh2 1.4.3 编译的。

关于php - 警告 : ssh2_connect(): Failed overriding server to client COMP method,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27960200/

相关文章:

php - 什么是可以在 PHP 5.3 上解析和重建 SQL 查询的优秀查询生成器?

php imap foward/redirect 帐户获取原始地址(送达)

Java 控制 Windows 服务器

iphone - 如何压缩多个图像并从 iPhone 应用程序上传到 FTP 服务器?

php - 如何强制 Composer 使用 https ://instead of git://?

git - Windows VS Code 能否在连接到 git 存储库的 Ubuntu 主机上通过 ssh 运行 git 命令

ssh - 系统命令执行但立即后台

jquery - 如何在 Django 中压缩 JSON 请求?

c - 从 C 中具有多个 NULL '\0' 的函数返回字符串

php - 将多个文本文件及其标题导入 MySQL