У меня проблема с включением сжатия для сессии SSH в PHP.
Часть кода:
$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.com
, zlib
, а также none
пока сервер поддерживает только zlib@openssh.com
а также none
Таким образом, процесс обмена ключами в конечном итоге основывается на использовании zlib@openssh.com
,
К сожалению, поддержка типа сжатия zlib@openssh.com
не был добавлен в libssh2 до 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.
Других решений пока нет …