# 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`退出控制台

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