def parse_console(vm_console, key_types=('ssh-ed25519', 'ecdsa-sha2-nistp256')):
    """Parse SSH keys from AWS vm console.
    """
    begin = "-----BEGIN SSH HOST KEY KEYS-----"
    end = "-----END SSH HOST KEY KEYS-----"
    keys = []

    if not vm_console:
        return None

    # find SSH signatures
    p1 = vm_console.find(begin)
    if p1 < 0:
        return None
    p2 = vm_console.find(end, p1)
    if p2 < 0:
        return None

    # parse lines
    klines = vm_console[p1 + len(begin):p2]
    for kln in klines.split('\n'):
        pos = kln.find('ecdsa-')
        if pos < 0:
            pos = kln.find('ssh-')
            if pos < 0:
                continue
        kln = kln[pos:].strip()
        ktype, kcert, kname = kln.split(' ')
        if ktype not in key_types:
            continue
        keys.append((ktype, kcert))

    if not keys:
        raise IOError("Failed to get SSH keys")

    return keys