diff options
author | Martin Topholm <mph@one.com> | 2015-03-02 07:17:50 +0100 |
---|---|---|
committer | Jeff Forcier <jeff@bitprophet.org> | 2015-09-30 14:16:28 -0700 |
commit | 669ecbd66f1218e5c93f6a53a25ea062c7b0b947 (patch) | |
tree | 13b30c2ba11ebe07a43fb81b47944526c793281a /paramiko/hostkeys.py | |
parent | 48dc72b87567152ac8d45b4bad2bdd0d4ad3ac8b (diff) | |
download | paramiko-669ecbd66f1218e5c93f6a53a25ea062c7b0b947.tar.gz |
Silently ignore invalid keys in HostKeys.load()
When broken entries exists in known_hosts, paramiko raises SSHException
with "Invalid key". This patch catches the exception during
HostKeys.load() and continues to next line.
This should fix #490.
Diffstat (limited to 'paramiko/hostkeys.py')
-rw-r--r-- | paramiko/hostkeys.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/paramiko/hostkeys.py b/paramiko/hostkeys.py index 84868875..7e2d22cf 100644 --- a/paramiko/hostkeys.py +++ b/paramiko/hostkeys.py @@ -19,6 +19,7 @@ import binascii import os +import ssh_exception from hashlib import sha1 from hmac import HMAC @@ -96,7 +97,10 @@ class HostKeys (MutableMapping): line = line.strip() if (len(line) == 0) or (line[0] == '#'): continue - e = HostKeyEntry.from_line(line, lineno) + try: + e = HostKeyEntry.from_line(line, lineno) + except ssh_exception.SSHException: + continue if e is not None: _hostnames = e.hostnames for h in _hostnames: |