def _get_host_key_map(known_host_lines):
    """
    See https://man.openbsd.org/sshd.8#SSH_KNOWN_HOSTS_FILE_FORMAT
    :param known_host_lines: lines in known_hosts format
    :return: dict((hostname, key_type) -> key
    """
    keys_by_host = {}
    for line in known_host_lines:
        if not line:
            continue
        csv_hosts, key_type, key = line.split(' ')
        # filter out empty hosts ('[]:port' is empty host with non-standard port)
        hosts = [h for h in csv_hosts.split(',') if h and '[]' not in h]
        for host in hosts:
            keys_by_host[(host, key_type)] = key
    return keys_by_host