@decorators.which('ssh-keygen')
def hash_known_hosts(user=None, config=None):
 full = _get_known_hosts_file(config=config, user=user)
 if isinstance(full, dict):
  return full
 if (not os.path.isfile(full)):
  return {'status': 'error', 'error': 'Known hosts file {0} does not exist'.format(full)}
 origmode = os.stat(full).st_mode
 cmd = ['ssh-keygen', '-H', '-f', full]
 cmd_result = __salt__['cmd.run'](cmd, python_shell=False)
 os.chmod(full, origmode)
 if ((os.geteuid() == 0) and user):
  uinfo = __salt__['user.info'](user)
  os.chown(full, uinfo['uid'], uinfo['gid'])
 return {'status': 'updated', 'comment': cmd_result}

@ decorators . which ( 'ssh-keygen' ) def hash_known_hosts ( user = None , config = None ) : full = _get_known_hosts_file ( config = config , user = user ) if isinstance ( full , dict ) : return full if ( not os . path . isfile ( full ) ) : return { 'status' : 'error' , 'error' : 'Known hosts file {0} does not exist' . format ( full ) } origmode = os . stat ( full ) . st_mode cmd = [ 'ssh-keygen' , '-H' , '-f' , full ] cmd_result = __salt__ [ 'cmd.run' ] ( cmd , python_shell = False ) os . chmod ( full , origmode ) if ( ( os . geteuid ( ) == 0 ) and user ) : uinfo = __salt__ [ 'user.info' ] ( user ) os . chown ( full , uinfo [ 'uid' ] , uinfo [ 'gid' ] ) return { 'status' : 'updated' , 'comment' : cmd_result }
hash all the hostnames in the known hosts file .