Skip to content

Commit

Permalink
Silently ignore invalid keys in HostKeys.load()
Browse files Browse the repository at this point in the history
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 paramiko#490.
  • Loading branch information
martintopholm authored and bitprophet committed Sep 30, 2015
1 parent 3deebb3 commit dd458ab
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion hostkeys.py
Expand Up @@ -19,6 +19,7 @@

import binascii
import os
import ssh_exception

from hashlib import sha1
from hmac import HMAC
Expand Down Expand Up @@ -96,7 +97,10 @@ def load(self, filename):
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:
Expand Down

0 comments on commit dd458ab

Please sign in to comment.