code: def ssh_known_host_key(host, application_name, user=None):
      
      cmd = [
          'ssh-keygen',
          '-f', known_hosts(application_name, user),
          '-H',
          '-F',
          host]
      try:
          # The first line of output is like '# Host xx found: line 1 type RSA',
          # which should be excluded.
          output = subprocess.check_output(cmd)
      except subprocess.CalledProcessError as e:
          # RC of 1 seems to be legitimate for most ssh-keygen -F calls.
          if e.returncode == 1:
              output = e.output
          else:
              raise
      output = output.strip()
  
      if output:
          # Bug #1500589 cmd has 0 rc on precise if entry not present
          lines = output.split('\n')
          if len(lines) >= 1:
              return lines[0]
  
      return None
docs: Return the first entry in known_hosts for host.
  
      :param host: hostname to lookup in file.
      :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
      :returns: Host key
      :rtype: str or None