stage | group | info | type |
---|---|---|---|
Manage |
Authentication and Authorization |
To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/product/ux/technical-writing/#assignments |
howto |
You can reset user passwords by using the UI, a Rake task, a Rails console, or the Users API.
To reset a user password, you must be an administrator of a self-managed GitLab instance.
The user's new password must meet all password requirements.
To reset a user's password in the UI:
- On the left sidebar, expand the top-most chevron ({chevron-down}).
- Select Admin Area.
- On the left sidebar, select Overview > Users.
- For the user whose password you want to update, select Edit.
- In the Password area, type a password and password confirmation.
- Select Save changes.
A confirmation is displayed.
Introduced in GitLab 13.9.
Use the following Rake task to reset a user's password:
-
For Omnibus installations
sudo gitlab-rake "gitlab:password:reset"
-
For installations from source
bundle exec rake "gitlab:password:reset"
GitLab requests a username, a password, and confirmation of the password. When complete, the user's password is updated.
The Rake task can take a username as an argument. For example, to reset the password for the user with username
sidneyjones
:
-
For Omnibus installations
sudo gitlab-rake "gitlab:password:reset[sidneyjones]"
-
For installations from source
bundle exec rake "gitlab:password:reset[sidneyjones]"
If you know the username, user ID, or email address, you can use the Rails console to reset their password:
-
Open a Rails console.
-
Find the user:
-
By username:
user = User.find_by_username 'exampleuser'
-
By user ID:
user = User.find(123)
-
By email address:
user = User.find_by(email: '[email protected]')
-
-
Reset the password by setting a value for
user.password
anduser.password_confirmation
. For example, to set a new random password:new_password = ::User.random_password user.password = new_password user.password_confirmation = new_password
To set a specific value for the new password:
new_password = 'examplepassword' user.password = new_password user.password_confirmation = new_password
-
Optional. Notify the user that an administrator changed their password:
user.send_only_admin_changed_your_password_notification!
-
Save the changes:
user.save!
-
Exit the console:
exit
To reset the root password, follow the steps listed previously.
- If the root account name hasn't changed, use the username
root
. - If the root account name has changed and you don't know the new username,
you might be able to use a Rails console with user ID
1
. In almost all cases, the first user is the default administrator account.
Use the following information to troubleshoot issues when resetting a user's password.
If the new password doesn't work, it might be an email confirmation issue. You can
attempt to fix this issue in a Rails console. For example, if a new root
password isn't working:
-
Start a Rails console.
-
Find the user and skip reconfirmation:
user = User.find(1) user.skip_reconfirmation!
-
Attempt to sign in again.
The password might be too short, too weak, or not meet complexity requirements. Ensure the password you are attempting to set meets all password requirements.