def _validate_keys(key_file):
 ret = {}
 linere = re.compile('^(.*?)\\s?((?:ssh\\-|ecds)[\\w-]+\\s.+)$')
 try:
  with salt.utils.fopen(key_file, 'r') as _fh:
   for line in _fh:
    if line.startswith('#'):
     continue
    search = re.search(linere, line)
    if (not search):
     continue
    opts = search.group(1)
    comps = search.group(2).split()
    if (len(comps) < 2):
     continue
    if opts:
     options = opts.split(',')
    else:
     options = []
    enc = comps[0]
    key = comps[1]
    comment = ' '.join(comps[2:])
    fingerprint = _fingerprint(key)
    if (fingerprint is None):
     continue
    ret[key] = {'enc': enc, 'comment': comment, 'options': options, 'fingerprint': fingerprint}
 except (IOError, OSError):
  raise CommandExecutionError('Problem reading ssh key file {0}'.format(key_file))
 return ret

def _validate_keys ( key_file ) : ret = { } linere = re . compile ( '^(.*?)\\s?((?:ssh\\-|ecds)[\\w-]+\\s.+)$' ) try : with salt . utils . fopen ( key_file , 'r' ) as _fh : for line in _fh : if line . startswith ( '#' ) : continue search = re . search ( linere , line ) if ( not search ) : continue opts = search . group ( 1 ) comps = search . group ( 2 ) . split ( ) if ( len ( comps ) < 2 ) : continue if opts : options = opts . split ( ',' ) else : options = [ ] enc = comps [ 0 ] key = comps [ 1 ] comment = ' ' . join ( comps [ 2 : ] ) fingerprint = _fingerprint ( key ) if ( fingerprint is None ) : continue ret [ key ] = { 'enc' : enc , 'comment' : comment , 'options' : options , 'fingerprint' : fingerprint } except ( IOError , OSError ) : raise CommandExecutionError ( 'Problem reading ssh key file {0}' . format ( key_file ) ) return ret
return a dict containing validated keys in the passed file .