Exception: Net::SSH::HostKeyMismatch
- Defined in:
- lib/net/ssh/errors.rb
Overview
Raised when the cached key for a particular host does not match the key given by the host, which can be indicative of a man-in-the-middle attack. When rescuing this exception, you can inspect the key fingerprint and, if you want to proceed anyway, simply call the remember_host! method on the exception, and then retry.
Instance Attribute Summary collapse
-
#callback ⇒ Object
writeonly
the callback to use when #remember_host! is called.
-
#data ⇒ Object
writeonly
situation-specific data describing the host (see #host, #port, etc.).
Instance Method Summary collapse
-
#[](key) ⇒ Object
An accessor for getting at the data that was used to look up the host (see also #fingerprint, #host, #port, #ip, and #key).
-
#fingerprint ⇒ Object
Returns the fingerprint of the key for the host, which either was not found or did not match.
-
#host ⇒ Object
Returns the host name for the remote host, as reported by the socket.
-
#ip ⇒ Object
Returns the IP address of the remote host, as reported by the socket.
-
#key ⇒ Object
Returns the key itself, as reported by the remote host.
-
#port ⇒ Object
Returns the port number for the remote host, as reported by the socket.
-
#remember_host! ⇒ Object
Tell Net::SSH to record this host and key in the known hosts file, so that subsequent connections will remember them.
Instance Attribute Details
#callback=(value) ⇒ Object (writeonly)
the callback to use when #remember_host! is called
42 43 44 |
# File 'lib/net/ssh/errors.rb', line 42 def callback=(value) @callback = value end |
#data=(value) ⇒ Object (writeonly)
situation-specific data describing the host (see #host, #port, etc.)
45 46 47 |
# File 'lib/net/ssh/errors.rb', line 45 def data=(value) @data = value end |
Instance Method Details
#[](key) ⇒ Object
An accessor for getting at the data that was used to look up the host (see also #fingerprint, #host, #port, #ip, and #key).
49 50 51 |
# File 'lib/net/ssh/errors.rb', line 49 def [](key) @data && @data[key] end |
#fingerprint ⇒ Object
Returns the fingerprint of the key for the host, which either was not found or did not match.
55 56 57 |
# File 'lib/net/ssh/errors.rb', line 55 def fingerprint @data && @data[:fingerprint] end |
#host ⇒ Object
Returns the host name for the remote host, as reported by the socket.
60 61 62 |
# File 'lib/net/ssh/errors.rb', line 60 def host @data && @data[:peer] && @data[:peer][:host] end |
#ip ⇒ Object
Returns the IP address of the remote host, as reported by the socket.
70 71 72 |
# File 'lib/net/ssh/errors.rb', line 70 def ip @data && @data[:peer] && @data[:peer][:ip] end |
#key ⇒ Object
Returns the key itself, as reported by the remote host.
75 76 77 |
# File 'lib/net/ssh/errors.rb', line 75 def key @data && @data[:key] end |
#port ⇒ Object
Returns the port number for the remote host, as reported by the socket.
65 66 67 |
# File 'lib/net/ssh/errors.rb', line 65 def port @data && @data[:peer] && @data[:peer][:port] end |
#remember_host! ⇒ Object
Tell Net::SSH to record this host and key in the known hosts file, so that subsequent connections will remember them.
81 82 83 |
# File 'lib/net/ssh/errors.rb', line 81 def remember_host! @callback.call end |