Exception: Net::SSH::HostKeyError
- Defined in:
- lib/net/ssh/errors.rb
Overview
Base class for host key exceptions. 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.
Direct Known Subclasses
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 that was connected to.
-
#ip ⇒ Object
Returns the IP address of the remote host, as reported by the socket, or nil when connected through a ProxyCommand.
-
#key ⇒ Object
Returns the key itself, as reported by the remote host.
-
#port ⇒ Object
Returns the port number that was connected to.
-
#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
58 59 60 |
# File 'lib/net/ssh/errors.rb', line 58 def callback=(value) @callback = value end |
#data=(value) ⇒ Object (writeonly)
situation-specific data describing the host (see #host, #port, etc.)
61 62 63 |
# File 'lib/net/ssh/errors.rb', line 61 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).
65 66 67 |
# File 'lib/net/ssh/errors.rb', line 65 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.
71 72 73 |
# File 'lib/net/ssh/errors.rb', line 71 def fingerprint @data && @data[:fingerprint] end |
#host ⇒ Object
Returns the host name that was connected to.
76 77 78 |
# File 'lib/net/ssh/errors.rb', line 76 def host session&.host end |
#ip ⇒ Object
Returns the IP address of the remote host, as reported by the socket, or nil when connected through a ProxyCommand.
87 88 89 90 |
# File 'lib/net/ssh/errors.rb', line 87 def ip peer_ip = session&.socket&.peer_ip peer_ip unless peer_ip == Net::SSH::Transport::PacketStream::PROXY_COMMAND_HOST_IP end |
#key ⇒ Object
Returns the key itself, as reported by the remote host.
93 94 95 |
# File 'lib/net/ssh/errors.rb', line 93 def key @data && @data[:key] end |
#port ⇒ Object
Returns the port number that was connected to.
81 82 83 |
# File 'lib/net/ssh/errors.rb', line 81 def port session&.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.
99 100 101 |
# File 'lib/net/ssh/errors.rb', line 99 def remember_host! @callback.call end |