在 ssh2_connect 中使用客户端到服务器 MAC 算法 hmac-sha2-256

Use client to server MAC algorithm hmac-sha2-256 in ssh2_connect

我正在尝试连接到我的 SFTP 服务器 (prosftpd),但是当我检查它的日志时,我发现:

2018-04-19 11:00:48,303 mod_sftp/0.9.9[18488]: no shared client-to-server MAC algorithm found (client sent 'hmac-sha1,hmac-sha1-96,hmac-md5,hmac-md5-96,hmac-ripemd160,hmac-ripemd160@openssh.com', server sent 'hmac-sha2-256,hmac-sha2-512,umac-64@openssh.com')

我尝试使用 "method" 参数:

ssh2_connect("my-sftp-server.com", 443, array(
    "client_to_server" => array(
      "mac" => 'hmac-sha2-256,hmac-sha2-512,umac-64@openssh.com'

但它不起作用,方法 ssh2_connect 似乎不支持此算法,在我的日志中我可以看到

client sent 'hmac-sha1,hmac-sha1-96,hmac-md5,hmac-md5-96,hmac-ripemd160,hmac-ripemd160@openssh.com'

有没有办法在我的 PHP SFTP 客户端上安装新的 MAC 算法?

PHP SSH2 package uses libssh2 library

hmac-sha2-256hmac-sha2-512 您需要 libssh2 version 1.7.0 (2016-02-23) 或更高版本。不支持 umac-64@openssh.com.


或者,您可以使用 phpseclib, which supports hmac-sha2-256 ever since version 0.3.8 (2014-09-12)。不支持 hmac-sha2-512,也不支持 umac-64@openssh.com