summaryrefslogtreecommitdiff
path: root/lib/net/ssh/known_hosts.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/net/ssh/known_hosts.rb')
-rw-r--r--lib/net/ssh/known_hosts.rb14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/net/ssh/known_hosts.rb b/lib/net/ssh/known_hosts.rb
index 7b153d4..7cbbdaf 100644
--- a/lib/net/ssh/known_hosts.rb
+++ b/lib/net/ssh/known_hosts.rb
@@ -11,6 +11,16 @@ module Net; module SSH
# by consumers of the library.
class KnownHosts
class <<self
+
+ if defined?(OpenSSL::PKey::EC)
+ SUPPORTED_TYPE = %w(ssh-rsa ssh-dss
+ ecdsa-sha2-nistp256
+ ecdsa-sha2-nistp384
+ ecdsa-sha2-nistp521)
+ else
+ SUPPORTED_TYPE = %w(ssh-rsa ssh-dss)
+ end
+
# Searches all known host files (see KnownHosts.hostfiles) for all keys
# of the given host. Returns an array of keys found.
def search_for(host, options={})
@@ -104,7 +114,7 @@ module Net; module SSH
scanner.skip(/\s*/)
type = scanner.scan(/\S+/)
- next unless %w(ssh-rsa ssh-dss).include?(type)
+ next unless SUPPORTED_TYPE.include?(type)
scanner.skip(/\s*/)
blob = scanner.rest.unpack("m*").first
@@ -126,4 +136,4 @@ module Net; module SSH
end
end
-end; end \ No newline at end of file
+end; end