def rm_auth_key_from_file(user, source, config='.ssh/authorized_keys', saltenv='base'):
 lfile = __salt__['cp.cache_file'](source, saltenv)
 if (not os.path.isfile(lfile)):
  raise CommandExecutionError('Failed to pull key file from salt file server')
 s_keys = _validate_keys(lfile)
 if (not s_keys):
  err = 'No keys detected in {0}. Is file properly formatted?'.format(source)
  log.error(err)
  __context__['ssh_auth.error'] = err
  return 'fail'
 else:
  rval = ''
  for key in s_keys:
   rval += rm_auth_key(user, key, config)
  if ('Key not removed' in rval):
   return 'Key not removed'
  elif ('Key removed' in rval):
   return 'Key removed'
  else:
   return 'Key not present'

def rm_auth_key_from_file ( user , source , config = '.ssh/authorized_keys' , saltenv = 'base' ) : lfile = __salt__ [ 'cp.cache_file' ] ( source , saltenv ) if ( not os . path . isfile ( lfile ) ) : raise CommandExecutionError ( 'Failed to pull key file from salt file server' ) s_keys = _validate_keys ( lfile ) if ( not s_keys ) : err = 'No keys detected in {0}. Is file properly formatted?' . format ( source ) log . error ( err ) __context__ [ 'ssh_auth.error' ] = err return 'fail' else : rval = '' for key in s_keys : rval += rm_auth_key ( user , key , config ) if ( 'Key not removed' in rval ) : return 'Key not removed' elif ( 'Key removed' in rval ) : return 'Key removed' else : return 'Key not present'
remove an authorized key from the specified users authorized key file .