code: def add_known_host(host, application_name, user=None):
      
      cmd = ['ssh-keyscan', '-H', '-t', 'rsa', host]
      try:
          remote_key = subprocess.check_output(cmd).strip()
      except Exception as e:
          log('Could not obtain SSH host key from %s' % host, level=ERROR)
          raise e
  
      current_key = ssh_known_host_key(host, application_name, user)
      if current_key and remote_key:
          if is_same_key(remote_key, current_key):
              log('Known host key for compute host %s up to date.' % host)
              return
          else:
              remove_known_host(host, application_name, user)
  
      log('Adding SSH host key to known hosts for compute node at %s.' % host)
      with open(known_hosts(application_name, user), 'a') as out:
          out.write("{}\n".format(remote_key))
docs: Add the given host key to the known hosts file.
  
      :param host: host name
      :type host: str
      :param application_name: Name of application eg nova-compute-something
      :type application_name: str
      :param user: The user that the ssh asserts are for.
      :type user: str