Reset user passwords
- Tier: Free, Premium, Ultimate
- Offering: GitLab Self-Managed, GitLab Dedicated
You can reset user passwords by using the UI, a Rake task, a Rails console, or the Users API.
Prerequisites
- You must be an administrator of GitLab Self-Managed.
- The new password must meet all password requirements.
Use the UI
To reset a user password in the UI:
- On the left sidebar, at the bottom, select Admin.
- Select Overview > Users.
- Identify a user account to update, select Edit.
- In the Password section, enter and confirm a new password.
- Select Save changes.
A confirmation is displayed.
Use a Rake task
To reset a user password with a Rake task:
sudo gitlab-rake "gitlab:password:reset"
bundle exec rake "gitlab:password:reset"
GitLab requests a username, a password, and confirmation of the password. When complete, the user password is updated.
The Rake task can accept a username as an argument. For example, to reset the password for the user with username
sidneyjones
:
sudo gitlab-rake "gitlab:password:reset[sidneyjones]"
bundle exec rake "gitlab:password:reset[sidneyjones]"
Use a Rails console
To reset a user password from a Rails console:
Prerequisites:
- You must know the associated username, user ID, or email address.
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: 'user@example.com')
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 user.password_automatically_set = false
To set a specific value for the new password:
new_password = 'examplepassword' user.password = new_password user.password_confirmation = new_password user.password_automatically_set = false
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
Reset the root password
You can reset the root password through the Rake task or Rails console processes outlined 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.
Troubleshooting
Use the following information to troubleshoot issues when resetting a user password.
Email confirmation issues
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.
Unmet password requirements
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.
Expired password
If a user password has previously expired, you might need to update the password expiration date. For more information, see Password expired error on Git fetch with SSH for LDAP user.
Docs
Edit this page to fix an error or add an improvement in a merge request.
Create an issue to suggest an improvement to this page.
Product
Create an issue if there's something you don't like about this feature.
Propose functionality by submitting a feature request.
Feature availability and product trials
View pricing to see all GitLab tiers and features, or to upgrade.
Try GitLab for free with access to all features for 30 days.
Get help
If you didn't find what you were looking for, search the docs.
If you want help with something specific and could use community support, post on the GitLab forum.
For problems setting up or using this feature (depending on your GitLab subscription).
Request support