Class: Net::SSH::Verifiers::Always
- Inherits:
-
Object
- Object
- Net::SSH::Verifiers::Always
- Defined in:
- lib/net/ssh/verifiers/always.rb
Overview
Does a strict host verification, looking the server up in the known host files to see if a key has already been seen for this server. If this server does not appear in any host file, an exception will be raised (HostKeyUnknown). This is in contrast to the "Strict" class, which will silently add the key to your known_hosts file. If the server does appear at least once, but the key given does not match any known for the server, an exception will be raised (HostKeyMismatch). A key marked @revoked in a host file is always refused (HostKeyRevoked). Otherwise, this returns true.
Direct Known Subclasses
Instance Method Summary collapse
Instance Method Details
#verify(arguments) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/net/ssh/verifiers/always.rb', line 17 def verify(arguments) refuse_revoked!(arguments) host_keys = arguments[:session].host_keys # We've never seen this host before, so raise an exception. process_cache_miss(host_keys, arguments, HostKeyUnknown, "is unknown") if host_keys.empty? # Find the known-hosts entry whose key matches the presented certificate. found_key = host_keys.find do |key| if key.respond_to?(:matches_key?) key.matches_key?(arguments[:key]) else key.ssh_type == arguments[:key].ssh_type && key.to_blob == arguments[:key].to_blob end end # No matching entry found — key is not recognized. process_cache_miss(host_keys, arguments, HostKeyMismatch, "does not match") unless found_key # For @cert-authority entries, enforce the certificate constraints # OpenSSH checks in sshkey_cert_check_authority. A certificate signed by # the trusted CA but failing any of these is rejected with # HostKeyMismatch (not HostKeyUnknown) so AcceptNew does not swallow the # failure and remember the rejected certificate. verify_certificate!(found_key, host_keys, arguments) true end |
#verify_signature(&block) ⇒ Object
47 48 49 |
# File 'lib/net/ssh/verifiers/always.rb', line 47 def verify_signature(&block) yield end |