From b0d63fbfb56222b3b14bc35aa6f6198b3b326d44 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Wed, 16 Jan 2019 21:15:11 -0600 Subject: [PATCH] SSH2: ssh-rsa is sometimes incorrectly used instead of rsa-sha2-256 --- phpseclib/Net/SSH2.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index 026f5e26..706e0482 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -1813,8 +1813,13 @@ class Net_SSH2 } if ($public_key_format != $expected_key_format || $this->signature_format != $server_host_key_algorithm) { - user_error('Server Host Key Algorithm Mismatch'); - return $this->_disconnect(NET_SSH2_DISCONNECT_KEY_EXCHANGE_FAILED); + switch (true) { + case $this->signature_format == $server_host_key_algorithm: + case $server_host_key_algorithm != 'rsa-sha2-256' && $server_host_key_algorithm != 'rsa-sha2-512': + case $this->signature_format != 'ssh-rsa': + user_error('Server Host Key Algorithm Mismatch'); + return $this->_disconnect(NET_SSH2_DISCONNECT_KEY_EXCHANGE_FAILED); + } } $packet = pack(