Create a user. Adds a key file to authorized_keys if given.
517783
def create_user(name, groups=None, key_file=None):
    """"""

    groups = groups or []
    if not user_exists(name):
        for group in groups:
            if not group_exists(group):
                sudo(u"addgroup %s" % group)
        groups = groups and u'-G %s' % u','.join(groups) or ''
        sudo(u"useradd -m %s -s /bin/bash %s" % (groups, name))
        sudo(u"passwd -d %s" % name)
    if key_file:
        sudo(u"mkdir -p /home/%s/.ssh" % name)
        put(key_file, u"/home/%s/.ssh/authorized_keys" % name, use_sudo=True)
        sudo(u"chown -R %(name)s:%(name)s /home/%(name)s/.ssh" % {'name': name})
804671
def add_user(self, user, **kwargs):
        """"""
        if isinstance(user, User):
            user = user['id']

        assert isinstance(user, six.string_types)

        endpoint = '{0}/{1}/users/{2}'.format(
            self.endpoint,
            self['id'],
            user,
        )
        result = self.request('PUT', endpoint=endpoint, query_params=kwargs)
        return result
1351970
protected void addUser(String key, User<PERM> user) {
		userMap.put(key, user);
	}
610111
def _AddUser(self, user):
    
    self.logger.info('Creating a new user account for %s.', user)

    command = self.useradd_cmd.format(user=user)
    try:
      subprocess.check_call(command.split(' '))
    except subprocess.CalledProcessError as e:
      self.logger.warning('Could not create user %s. %s.', user, str(e))
      return False
    else:
      self.logger.info('Created user account %s.', user)
      return True
1111273
def create_user(self, username, password, family_name, given_name, primary_email,
            details={}):
        
        self.assert_has_permission('scim.write')

        data = {
            'userName': username,
            'password': password,
            'name': {
                'familyName': family_name,
                'givenName': given_name,
                },
            'emails': [{
                'value': primary_email,
                'primary': True,
                }]
            }

        if details:
            data.update(details)

        return self._post_user(data)
107223
def user_create(self, data, **kwargs):
        ""
        api_path = "/api/v2/users.json"
        return self.call(api_path, method="POST", data=data, **kwargs)
998167
def create_user(self, username, password, roles):
    
    return users.create_user(self, username, password, roles)
247785
def create_user(self, **kwargs):
        """"""
        kwargs = self._prepare_create_user_args(**kwargs)
        user = self.user_model(**kwargs)
        return self.put(user)
52903
def create():
    ''''''
    data = {
        'first_name': click.prompt('First name'),
        'last_name': click.prompt('Last name'),
        'email': click.prompt('Email'),
        'password': click.prompt('Password', hide_input=True),
        'password_confirm': click.prompt('Confirm Password', hide_input=True),
    }
    # Until https://github.com/mattupstate/flask-security/issues/672 is fixed
    with current_app.test_request_context():
        form = RegisterForm(MultiDict(data), meta={'csrf': False})
    if form.validate():
        data['password'] = encrypt_password(data['password'])
        del data['password_confirm']
        data['confirmed_at'] = datetime.utcnow()
        user = datastore.create_user(**data)
        success('User(id={u.id} email={u.email}) created'.format(u=user))
        return user
    errors = '\n'.join('\n'.join(e) for e in form.errors.values())
    exit_with_error('Error creating user', errors)
889291
def create(self, request, *args, **kwargs):
        """"""
        if not request.user.is_authenticated:
            raise exceptions.NotFound

        return super().create(request, *args, **kwargs)
712571
async def add_ssh_key(self, user, key):
        
        key_facade = client.KeyManagerFacade.from_connection(self.connection())
        return await key_facade.AddKeys([key], user)
1371824
def add_user(self, username, password):
        """"""
        self.server.user_dict[username] = password
        self.server.isAuth = True
527552
def authorize(ctx, public_key, append):
    
    wva = get_wva(ctx)

    http_client = wva.get_http_client()
    authorized_keys_uri = "/files/userfs/WEB/python/.ssh/authorized_keys"
    authorized_key_contents = public_key
    if append:
        try:
            existing_contents = http_client.get(authorized_keys_uri)
            authorized_key_contents = "{}\n{}".format(existing_contents, public_key)
        except WVAHttpNotFoundError:
            pass  # file doesn't exist, just write the public key
    http_client.put(authorized_keys_uri, authorized_key_contents)

    print("Public key written to authorized_keys for python user.")
    print("You should now be able to ssh to the device by doing the following:")
    print("")
    print("  $ ssh python@{}".format(get_root_ctx(ctx).hostname))
132386
def add(user_id, resource_policy, admin, inactive,  rate_limit):
    '''
    
    '''
    try:
        user_id = int(user_id)
    except ValueError:
        pass  # string-based user ID for Backend.AI v1.4+
    with Session() as session:
        try:
            data = session.KeyPair.create(
                user_id,
                is_active=not inactive,
                is_admin=admin,
                resource_policy=resource_policy,
                rate_limit=rate_limit)
        except Exception as e:
            print_error(e)
            sys.exit(1)
        if not data['ok']:
            print_fail('KeyPair creation has failed: {0}'.format(data['msg']))
            sys.exit(1)
        item = data['keypair']
        print('Access Key: {0}'.format(item['access_key']))
        print('Secret Key: {0}'.format(item['secret_key']))
1169882
def create_db_user(username, password=None, flags=None):
    """"""

    flags = flags or u'-D -A -R'
    sudo(u'createuser %s %s' % (flags, username), user=u'postgres')
    if password:
        change_db_user_password(username, password)
392909
def _add_ssh_key(ret):
    '''
    
    '''
    priv = None
    if __opts__.get('ssh_use_home_key') and os.path.isfile(os.path.expanduser('~/.ssh/id_rsa')):
        priv = os.path.expanduser('~/.ssh/id_rsa')
    else:
        priv = __opts__.get(
            'ssh_priv',
            os.path.abspath(os.path.join(
                __opts__['pki_dir'],
                'ssh',
                'salt-ssh.rsa'
            ))
        )
    if priv and os.path.isfile(priv):
        ret['priv'] = priv
272093
def add_to_user(self, name, **attrs):
        
        user = self.get_user(name=name)
        attrs_ = user['user']
        attrs_.update(**attrs)