Skip to content

Commit bb3c2a1

Browse files
committedAug 30, 2019
handle missing known_hosts
1 parent b50ffd9 commit bb3c2a1

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed
 

‎rsp/__main__.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,15 @@ def ssh_options_from_args(args, known_hosts):
110110

111111
async def amain(args, loop): # pragma: no cover
112112
logger = logging.getLogger('MAIN')
113-
known_hosts = asyncssh.read_known_hosts(args.hosts_file)
114-
host_keys, ca_keys, _, x509_certs, _, x509_subjects, _ = \
115-
known_hosts.match(args.dst_address, "", args.dst_port)
113+
114+
try:
115+
known_hosts = asyncssh.read_known_hosts(args.hosts_file)
116+
except Exception as exc:
117+
logger.error("Host keys loading failed with error: %s", str(exc))
118+
host_keys, ca_keys, x509_certs, x509_subjects = [], [], [], []
119+
else:
120+
host_keys, ca_keys, _, x509_certs, _, x509_subjects, _ = \
121+
known_hosts.match(args.dst_address, "", args.dst_port)
116122
if not ( host_keys or ca_keys or x509_certs or x509_subjects ):
117123
logger.critical("Specified host is not found in known hosts. "
118124
"Please run following command: "

0 commit comments

Comments
 (0)
Please sign in to comment.