541.md 990 字节
Newer Older
Lab机器人's avatar
readme  
Lab机器人 已提交
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
# How to unlock a locked user from the command line

> 原文:[https://docs.gitlab.com/ee/security/unlock_user.html](https://docs.gitlab.com/ee/security/unlock_user.html)

# How to unlock a locked user from the command line[](#how-to-unlock-a-locked-user-from-the-command-line "Permalink")

十次失败的登录尝试后,用户将进入锁定状态.

要解锁锁定的用户:

1.  SSH 到您的 GitLab 服务器.
2.  启动 Ruby on Rails 控制台:

    ```
    ## For Omnibus GitLab
    sudo gitlab-rails console -e production

    ## For installations from source
    sudo -u git -H bundle exec rails console -e production 
    ```

3.  查找要解锁的用户. 您可以通过电子邮件或 ID 进行搜索.

    ```
    user = User.find_by(email: 'admin@local.host') 
    ```

    or

    ```
    user = User.where(id: 1).first 
    ```

4.  解锁用户:

    ```
    user.unlock_access! 
    ```

5.  使用`Ctrl` + `d`退出控制台

用户现在应该可以登录了.