summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2016-08-29 21:22:34 -0700
committerelijah <elijah@riseup.net>2016-08-29 21:22:34 -0700
commit568688b5a7d17de26a275a2f6dde8bbd3054cdc6 (patch)
tree1cae7d227cbb703dc67492b5b0c47088220eca58 /lib
parent96fee2dcd94bd887a0855b2e9c4216462c3ccd87 (diff)
ssh: Added verbose error message when host key mismatch occurs in net::ssh.
Diffstat (limited to 'lib')
-rw-r--r--lib/leap_cli/ssh/backend.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/leap_cli/ssh/backend.rb b/lib/leap_cli/ssh/backend.rb
index 42e58c15..c1afc993 100644
--- a/lib/leap_cli/ssh/backend.rb
+++ b/lib/leap_cli/ssh/backend.rb
@@ -153,6 +153,23 @@ module LeapCli
#
def rescue_ssh_errors(*args, &block)
yield
+ rescue Net::SSH::HostKeyMismatch => exc
+ @logger.log(:fatal_error, "Host key mismatch!") do
+ @logger.log(exc.to_s)
+ @logger.log("The ssh host key for the server does not match what is on "+
+ " file in `%s`." % Path.named_path(:known_hosts))
+ @logger.log("One of these is happening:") do
+ @logger.log("There is an active Man in The Middle attack against you.")
+ @logger.log("Or, someone has generated new host keys for the server " +
+ "and your provider files are out of date.")
+ @logger.log("Or, a new server is using this IP address " +
+ "and your provider files are out of date.")
+ @logger.log("Or, the server configuration has changed to use a different host key.")
+ end
+ @logger.log("You can pin a different host key using `leap node init NODE`, " +
+ "but you must verify the fingerprint of the new host key!")
+ end
+ exit(1)
rescue StandardError => exc
if exc.is_a?(SSHKit::Command::Failed) || exc.is_a?(SSHKit::Runner::ExecuteError)
if @options[:raise_error]