summaryrefslogtreecommitdiff
path: root/lib/net/ssh/errors.rb
diff options
context:
space:
mode:
authorJamis Buck <jamis@37signals.com>2007-08-09 02:32:27 +0000
committerJamis Buck <jamis@37signals.com>2007-08-09 02:32:27 +0000
commitca4605cb6a7173408355ced704cb6377a3d920fd (patch)
tree1977aae92bdc7df61dcec541a78fc7206b84b220 /lib/net/ssh/errors.rb
parent6c1665335aeeb72f68110a511057ce658a2fb519 (diff)
downloadnet-ssh-ca4605cb6a7173408355ced704cb6377a3d920fd.tar.gz
host key verification
git-svn-id: http://svn.jamisbuck.org/net-ssh/branches/v2@138 1d2a57f2-1ded-0310-ad52-83097a15a5de
Diffstat (limited to 'lib/net/ssh/errors.rb')
-rw-r--r--lib/net/ssh/errors.rb37
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/net/ssh/errors.rb b/lib/net/ssh/errors.rb
index 956b951..724ff67 100644
--- a/lib/net/ssh/errors.rb
+++ b/lib/net/ssh/errors.rb
@@ -4,4 +4,41 @@ module Net; module SSH
class AuthenticationFailed < Exception; end
class Disconnect < Exception; end
+
+ # 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.
+ class HostKeyMismatch < Exception
+ attr_writer :callback, :data
+
+ def [](key)
+ @data[key]
+ end
+
+ def fingerprint
+ @data[:fingerprint]
+ end
+
+ def host
+ @data[:peer][:host]
+ end
+
+ def port
+ @data[:peer][:port]
+ end
+
+ def ip
+ @data[:peer][:ip]
+ end
+
+ def key
+ @data[:key]
+ end
+
+ def remember_host!
+ @callback.call
+ end
+ end
end; end \ No newline at end of file