Skip to content

Commit

Permalink
In hasHostKey(), check the host key type when parsing ~/.ssh/known_hosts
Browse files Browse the repository at this point in the history
If we have an ecdsa-nistp-256 key in known_hosts, but the
server offers an ssh-rsa key, this will cause conch to skip the
entry instead of raising a bad host key error.
  • Loading branch information
rodrigc committed Dec 27, 2016
1 parent d5dacf3 commit 061ef64
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/twisted/conch/client/knownhosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ def hasHostKey(self, hostname, key):
does not match the given key.
"""
for lineidx, entry in enumerate(self.iterentries(), -len(self._added)):
if entry.matchesHost(hostname):
if entry.matchesHost(hostname) and entry.keyType == key.sshType():
if entry.matchesKey(key):
return True
else:
Expand Down

0 comments on commit 061ef64

Please sign in to comment.