在 Ubuntu 上重置 GitLab 密码,通常有以下几种常见场景和方法:
sudo gitlab-rails console -e production
(如果是源码安装,可能是 bundle exec rails console production)
user = User.where(username: 'root').first
# 或者按邮箱
# user = User.find_by(email: 'admin@example.com')
user.password = 'newpassword123'
user.password_confirmation = 'newpassword123'
user.save!
exit
✅ 现在可以用新密码登录 GitLab Web 页面。
上述方法同样适用,不需要原密码。
如果你是 Omnibus 安装(最常见):
sudo gitlab-ctl reconfigure
sudo gitlab-rails console -e production
如果你指的是 Ubuntu 系统里的 git 用户密码:
sudo passwd git
如果是 Docker 容器:
docker exec -it gitlab bash
gitlab-rails console -e production
然后执行上面的 Ruby 命令。
https://your-gitlab-domaincurl -X POST "https://gitlab.example.com/api/v4/session" \
--data "login=root&password=newpassword123"
如果你能说明:
我可以给你更精确的步骤。