Skip to content

Commit

Permalink
Handle case where remote host SSH key doesn't match known_hosts.
Browse files Browse the repository at this point in the history
  • Loading branch information
bitprophet committed Jun 6, 2009
1 parent 30708fb commit ff82cf9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions fabric/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ def connect(user, host, port):
key_filename=env.key_filename, timeout=10)
connected = True
return client
# BadHostKeyException corresponds to key mismatch, i.e. what on the
# command line results in the big banner error about man-in-the-middle
# attacks.
except ssh.BadHostKeyException:
abort("Host key for %s did not match pre-existing key! Server's key was changed recently, or possible man-in-the-middle attack." % env.host)
# Prompt for new password to try on auth failure
except (
ssh.AuthenticationException,
Expand Down

0 comments on commit ff82cf9

Please sign in to comment.