Methods
Public Instance methods
[ show source ]
# File lib/net/ssh/host-key-verifier.rb, line 8
8: def verify(arguments)
9: host = canonize(arguments[:peer])
10: matches = Net::SSH::KnownHosts.search_for(host)
11:
12: # we've never seen this host before, so just automatically add the key.
13: # not the most secure option (since the first hit might be the one that
14: # is hacked), but since almost nobody actually compares the key
15: # fingerprint, this is a reasonable compromise between usability and
16: # security.
17: if matches.empty?
18: Net::SSH::KnownHosts.add(host, arguments[:key])
19: return true
20: end
21:
22: # If we found any matches, check to see that the key type and
23: # blob also match.
24: found = matches.any? do |key|
25: key.ssh_type == arguments[:key].ssh_type &&
26: key.to_blob == arguments[:key].to_blob
27: end
28:
29: # If a match was found, return true. Otherwise, raise an exception
30: # indicating that the key was not recognized.
31: found || process_cache_miss(host, arguments)
32: end