Check if known_hosts attribute exists before trying to read it.