在 Linux 上修改 GitLab 密码 常见有几种场景,下面按最常用的情况给你说明:
# 进入 GitLab 安装目录(Omnibus 默认)
sudo gitlab-rails console -e production
进入后执行:
user = User.find_by(username: 'root') # 或 email
user.password = 'NewPassword123'
user.password_confirmation = 'NewPassword123'
user.save!
退出:
exit
✅ 然后用新密码登录 Web 页面
sudo gitlab-rake "gitlab:password:reset[root]"
按提示输入新密码
如果你是说 Linux 服务器本身的用户密码:
passwd
# 或
sudo passwd gitlab
如果你是指 git pull/push 提示密码错误:
git config --global credential.helper cache
或修改远程地址:
git remote set-url origin https://用户名:密码@gitlab.com/xxx.git
docker exec -it gitlab gitlab-rails console -e production
后续操作和上面一样
如果你能说明是:
我可以给你更精确的步骤。