Commit 921e8dea authored by Michal Čihař's avatar Michal Čihař

Return empty list of keys in case of error

parent cf2826b7
......@@ -163,12 +163,15 @@ def get_host_keys():
'''
Returns list of host keys.
'''
result = []
with open(os.path.expanduser('~/.ssh/known_hosts'), 'r') as handle:
for line in handle:
if ' ssh-rsa ' not in line:
continue
result.append(parse_hosts_line(line))
try:
result = []
with open(os.path.expanduser('~/.ssh/known_hosts'), 'r') as handle:
for line in handle:
if ' ssh-rsa ' not in line:
continue
result.append(parse_hosts_line(line))
except IOError:
return []
return result
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment