Welcome to mirror list, hosted at ThFree Co, Russian Federation.

reset_user_password.md « security « doc - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ed7b9f896167819e18da28c084c296c2367d8ab3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
---
stage: Manage
group: Access
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
type: howto
---

# How to reset user password

There are a few ways to reset the password of a user.

## Rake Task

GitLab provides a Rake Task to reset passwords of users using their usernames,
which can be invoked by the following command:

```shell
sudo gitlab-rake "gitlab:password:reset"
```

You will be asked for username, password, and password confirmation. Upon giving
proper values for them, the password of the specified user will be updated.

The Rake task also takes the username as an argument, as shown in the example
below:

```shell
sudo gitlab-rake "gitlab:password:reset[johndoe]"
```

NOTE:
To reset the default admin password, run this Rake task with the username
`root`, which is the default username of that admin account.

## Rails console

The Rake task is capable of finding users via their usernames. However, if only
user ID or email ID of the user is known, Rails console can be used to find user
using user ID and then change password of the user manually.

1. Start a Rails console

    ```shell
    sudo gitlab-rails console -e production
    ```

1. Find the user either by user ID or email ID:

    ```ruby
    user = User.find(123)

    #or

    user = User.find_by(email: 'user@example.com')
    ```

1. Reset the password

    ```ruby
    user.password = 'secret_pass'
    user.password_confirmation = 'secret_pass'
    ```

1. When using this method instead of the [Users API](../api/users.md#user-modification),
   GitLab sends an email to the user stating that the user changed their
   password. If the password was changed by an administrator, execute the
   following command to notify the user by email:

    ```ruby
    user.send_only_admin_changed_your_password_notification!
    ```

1. Save the changes:

    ```ruby
    user.save!
    ```

1. Exit the console, and then try to sign in with your new password.

NOTE:
You can also reset passwords by using the [Users API](../api/users.md#user-modification).

## Reset your root password

The previously described steps can also be used to reset the root password.

In normal installations where the username of root account hasn't been changed
manually, the Rake task can be used with username `root` to reset the root
password.

If the username was changed to something else and has been forgotten, one
possible way is to reset the password using Rails console with user ID `1` (in
almost all the cases, the first user will be the default admin account).

<!-- ## Troubleshooting

Include any troubleshooting steps that you can foresee. If you know beforehand what issues
one might have when setting this up, or when something is changed, or on upgrading, it's
important to describe those, too. Think of things that may go wrong and include them here.
This is important to minimize requests for support, and to avoid doc comments with
questions that you know someone might ask.

Each scenario can be a third-level heading, e.g. `### Getting error message X`.
If you have none to add when creating a doc, leave this section in place
but commented out to help encourage others to add to it in the future. -->