def isInKnownHosts(host, pubKey, options):
    """
    Checks to see if host is in the known_hosts file for the user.

    @return: 0 if it isn't, 1 if it is and is the same, 2 if it's changed.
    @rtype: L{int}
    """
    keyType = common.getNS(pubKey)[0]
    retVal = 0

    if not options['known-hosts'] and not os.path.exists(os.path.expanduser('~/.ssh/')):
        print('Creating ~/.ssh directory...')
        os.mkdir(os.path.expanduser('~/.ssh'))
    kh_file = options['known-hosts'] or _KNOWN_HOSTS
    try:
        known_hosts = open(os.path.expanduser(kh_file), 'rb')
    except IOError:
        return 0
    with known_hosts:
        for line in known_hosts.readlines():
            split = line.split()
            if len(split) < 3:
                continue
            hosts, hostKeyType, encodedKey = split[:3]
            if host not in hosts.split(b','): # incorrect host
                continue
            if hostKeyType != keyType: # incorrect type of key
                continue
            try:
                decodedKey = decodebytes(encodedKey)
            except:
                continue
            if decodedKey == pubKey:
                return 1
            else:
                retVal = 2
    return retVal

    Checks to see if host is in the known_hosts file for the user.

    @return: 0 if it isn't, 1 if it is and is the same, 2 if it's changed.
    @rtype: L{int}
    
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/client/default.py