Metasploit uses an SSH implementation written in Ruby which only supports the algorithms listed below.
https://github.com/rapid7/metasploit-framework/blob/b3c7fff32a62739241a223515574674b4a6b483c/lib/net/ssh/transport/algorithms.rb#L31
ALGORITHMS = {
:host_key => %w(ssh-rsa ssh-dss),
:kex => %w(diffie-hellman-group-exchange-sha1
diffie-hellman-group1-sha1),
:encryption => %w(aes128-cbc 3des-cbc blowfish-cbc cast128-cbc
aes192-cbc aes256-cbc [email protected]
idea-cbc none arcfour128 arcfour256),
:hmac => %w(hmac-sha1 hmac-md5 hmac-sha1-96 hmac-md5-96 none),
:compression => %w(none [email protected] zlib),
:language => %w()
}
The server needs to provide a match in each category to create a secure connection. Unfortunately, the Metasploit Ruby algorithms are considered weak by contemporary cryptographic standards, and newer OpenSSH server configurations disable them by default.
Metasploit would require additional Ruby code to implement newer algorithms. The server, however, can enable additional algorithms in the sshd_config
. Modify /etc/ssh/sshd_config
to specify compatible algorithms:
# Metasploit Client
KexAlgorithms diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
Ciphers aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256cbc,arcfour128,arcfour256
# Unsupported Ciphers from Metasploit: [email protected],idea-cbc,none
MACs hmac-sha1,hmac-md5,hmac-sha1-96,hmac-md5-96
# Unsupported MACs from Metasploit: none
This will totally replace the server's algorithms with weaker ones. A better solution would be to add the algorithms, or some subset, to the defaults. Unfortunately, the configuration options require complete specification, so it is OpenSSH version dependant. Defaults can be found in man sshd_config
and then specified with the above options as additions.
For Fedora 22, it would be something like:
Ciphers aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected],[email protected],aes128-cbc
KexAlgorithms [email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1
MACs [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1