Check to see if a key needs updating, returns "update", "add" or "exists"

    CLI Example:

    .. code-block:: bash

        salt '*' ssh.check_key <user> <key> <enc> <comment> <options>
540801
def check_key(user,
              key,
              enc,
              comment,
              options,
              config='.ssh/authorized_keys',
              cache_keys=None,
              fingerprint_hash_type=None):
    '''
    
    '''
    if cache_keys is None:
        cache_keys = []
    enc = _refine_enc(enc)
    current = auth_keys(user,
                        config=config,
                        fingerprint_hash_type=fingerprint_hash_type)
    nline = _format_auth_line(key, enc, comment, options)

    # Removing existing keys from the auth_keys isn't really a good idea
    # in fact
    #
    # as:
    #   - We can have non-salt managed keys in that file
    #   - We can have multiple states defining keys for an user
    #     and with such code only one state will win
    #     the remove all-other-keys war
    #
    # if cache_keys:
    #     for pub_key in set(current).difference(set(cache_keys)):
    #         rm_auth_key(user, pub_key)

    if key in current:
        cline = _format_auth_line(key,
                                  current[key]['enc'],
                                  current[key]['comment'],
                                  current[key]['options'])
        if cline != nline:
            return 'update'
    else:
        return 'add'
    return 'exists'
163643
function update( hash, getKey, arr ) {
	var list,
		str,
		key,
		len,
		i;

	len = arr.length;
	for ( i = 0; i < len; i++ ) {
		str = arr[ i ];

		// Create a hash key...
		if ( str.length > 1 ) {
			key = getKey( str );
		} else {
			key = str;
		}
		// Check if key exists in the hash...
		if ( hash.hasOwnProperty( key ) ) {
			// Key already exists. Determine if we have already seen this string before...
			list = hash[ key ];
			if ( !contains( list, str ) ) {
				list.push ( str );
			}
		} else {
			hash[ key ] = [ str ];
		}
	}
}
150062
def check_args(hash)
        if !hash.include? :hostname
          raise ArgumentError, "You must provide a hostname"
        elsif !hash.include? :service_name
          raise ArgumentError, "You must provide a service name"
        elsif !hash.include? :return_code
          raise ArgumentError, "You must provide a return code"
        elsif !hash.include? :status
          raise ArgumentError, "You must provide a status"
        end
      end
509184
def ssh_check_mech(self, desired_mech):
        
        from pyasn1.codec.der import decoder

        mech, __ = decoder.decode(desired_mech)
        if mech.__str__() != self._krb5_mech:
            return False
        return True
209420
def ssh_accept(cfg, code, key_file, yes, **kwargs):
    

    for name, value in kwargs.items():
        setattr(cfg, name, value)
    from . import cmd_ssh
    kind, keyid, pubkey = cmd_ssh.find_public_key(key_file)
    print("Sending public key type='{}' keyid='{}'".format(kind, keyid))
    if yes is not True:
        click.confirm(
            "Really send public key '{}' ?".format(keyid), abort=True)
    cfg.public_key = (kind, keyid, pubkey)
    cfg.code = code

    return go(cmd_ssh.accept, cfg)
996567
def without_host_key_checking_linux
      tmpdir = ::Dir.mktmpdir
      ssh_cmd = ::File.join(tmpdir, 'ssh')

      ::File.open(ssh_cmd, 'w') do |cmd|
        cmd.puts "#!/bin/bash"
        cmd.puts "exec ssh -o StrictHostKeyChecking=no ${@}"
      end
      ::FileUtils.chmod(0700, ssh_cmd)

      old_env = ::ENV['GIT_SSH']
      ::ENV['GIT_SSH'] = ssh_cmd
      yield
    ensure
      ::FileUtils.rm_rf(tmpdir)
      ::ENV['GIT_SSH'] = old_env
    end
1082847
async def check_key(self, key, chat=None, user=None):
        
        if not self.storage.has_bucket():
            raise RuntimeError('This storage does not provide Leaky Bucket')

        if user is None and chat is None:
            user = types.User.get_current()
            chat = types.Chat.get_current()

        bucket = await self.storage.get_bucket(chat=chat, user=user)
        data = bucket.get(key, {})
        return Throttled(key=key, chat=chat, user=user, **data)
649685
def has(cmd):
    
    helps = ["--help", "-h", "--version"]
    if "nt" == os.name:
        helps.insert(0, "/?")
    fakecmd = "fakecmd"
    cmderr = strerr(fakecmd).replace(fakecmd, cmd)
    for h in helps:
        hcmd = "%s %s" % (cmd, h)
        if 0 == silent(hcmd):
            return True
        if len(listout(hcmd)) > 0:
            return True
        if strerr(hcmd) != cmderr:
            return True
    return False
1096514
def create(self, name, ssh_key, params=None):
        ''' 
        '''
        params = update_params(params, {
            'name': name,
            'ssh_key': ssh_key
        })
        return self.request('/v1/sshkey/create', params, 'POST')
853636
def exists(key, host=None, port=None, db=None, password=None):
    '''
    
    '''
    server = _connect(host, port, db, password)
    return server.exists(key)
1079642
def _UpdateUsers(self, update_users):
    
    for user, ssh_keys in update_users.items():
      if not user or user in self.invalid_users:
        continue
      configured_keys = self.user_ssh_keys.get(user, [])
      if set(ssh_keys) != set(configured_keys):
        if not self.utils.UpdateUser(user, ssh_keys):
          self.invalid_users.add(user)
        else:
          self.user_ssh_keys[user] = ssh_keys[:]
515112
def check_validity_for_dict(keys, dict):
    
    for key in keys:
        if key not in dict or dict[key] is '' or dict[key] is None:
            return False
    return True
908200
def check_required(self):
        
        die = False
        for key, value in self.spec.items():
            if not getattr(self, key.upper()) and value['required']:
                print(f"{key} is a required setting. "
                      "Set via command-line params, env or file. "
                      "For examples, try '--generate' or '--help'.")
                die = True
        if die:
            sys.exit(1)
1078660
def has_key?(key, opts={})
      key = normalize_key(key) if opts.fetch(:normalize, true)
      @source.has_key?(key)
    end
746733
def _check_avail(cmd):
    '''
    
    '''
    if isinstance(cmd, list):
        cmd = ' '.join([six.text_type(x) if not isinstance(x, six.string_types) else x
                        for x in cmd])
    bret = True
    wret = False
    if __salt__['config.get']('cmd_blacklist_glob'):
        blist = __salt__['config.get']('cmd_blacklist_glob', [])
        for comp in blist:
            if fnmatch.fnmatch(cmd, comp):
                # BAD! you are blacklisted
                bret = False
    if __salt__['config.get']('cmd_whitelist_glob', []):
        blist = __salt__['config.get']('cmd_whitelist_glob', [])
        for comp in blist:
            if fnmatch.fnmatch(cmd, comp):
                # GOOD! You are whitelisted
                wret = True
                break
    else:
        # If no whitelist set then alls good!
        wret = True
    return bret and wret
258494
def check_dependencies_remote(args):
    
    cmd = [args.python, '-m', 'depends', args.requirement]
    env = dict(PYTHONPATH=os.path.dirname(__file__))
    return subprocess.check_call(cmd, env=env)
225492
def has_key(self, key):
        
        if key in self._dict:
            try: 
                self[key]
                return True
            except ValueError:
                return False
            except KeyError:
                return False
        return False