code: def get_host_keys(hostname, sshdir):
      
      hostkey = None
  
      try:
          host_keys = load_host_keys(os.path.join(sshdir, 'known_hosts'))
      except IOError:
          host_keys = {}
  
      if hostname in host_keys:
          hostkeytype = host_keys[hostname].keys()[0]
          hostkey = host_keys[hostname][hostkeytype]
  
      return hostkey
docs: get host key