Php 警告:ssh2_connect():将服务器重写为客户端COMP方法失败
我在PHP中启用SSH会话压缩时遇到问题 代码的一部分:Php 警告:ssh2_connect():将服务器重写为客户端COMP方法失败,php,ssh,compression,Php,Ssh,Compression,我在PHP中启用SSH会话压缩时遇到问题 代码的一部分: $methods = array( 'server_to_client' => array( 'comp' => 'zlib') );if(!($con = ssh2_connect("10.214.201.31", 22, $methods))){ ... 执行过程中的警告(通过httpd或php cli): 压缩不起作用(通过ssh2\U scp\U recv下载测试文件的
$methods = array(
'server_to_client' => array(
'comp' => 'zlib')
);if(!($con = ssh2_connect("10.214.201.31", 22, $methods))){
...
执行过程中的警告(通过httpd或php cli):
压缩不起作用(通过ssh2\U scp\U 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.com
、zlib
和none
,而服务器仅支持zlib@openssh.com
和无
,因此密钥交换过程最终决定使用zlib@openssh.com
不幸的是,支持压缩类型zlib@openssh.com
是的,你猜对了,我的php5.4是用libssh1.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编译的。是否可以使用Putty以SSH方式连接到服务器(以证明凭据工作正常)?请确保您在PuttyYes中选择“启用压缩”,登录/通过很好,此代码运行良好(但下载速度太慢),因此我尝试添加压缩并节省一些执行时间。您可以发布PuTTY日志吗?选中“启用压缩”复选框并不一定意味着正在使用压缩。您可以通过启用日志记录来获取Putty日志。要做到这一点,请点击PuTTY->Session->Logging并检查“SSH packets”单选按钮。我没有使用PuTTY进行验证。我通过慢速VPN验证了WinSCP和100Mb文本(日志)文件下载。压缩后的下载速度提高了5倍。正如我前面提到的,我使用最新的php和libSSH版本libssh2/1.4.3。在WinSCP或Putty连接(带压缩)的情况下,Wireshark显示none,zlib@openssh.com
作为来自服务器的“密钥交换初始化”消息中的压缩,以及来自客户端的消息/回复中的zlib,无。在php ssh2连接的情况下,Wiresharkk显示来自服务器的相同“密钥交换初始化”消息,并且仅显示none
作为来自客户端的消息/回复中的压缩。所以我认为@openssh.com
不应该在压缩建立中有什么意义。
> 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