Linux 上 GitLab 登录不上通常不是单一原因,可先按下面思路快速定位。你没说清楚是 GitLab 网页打不开、SSH 登不上,还是 账号密码不对,所以我分情况说明。
sudo gitlab-ctl status
如果有 down 的服务:
sudo gitlab-ctl start
GitLab 默认端口:
检查端口:
sudo netstat -tulnp | grep 80
开放防火墙(示例):
sudo ufw allow 80
sudo ufw allow 443
查看配置:
sudo vi /etc/gitlab/gitlab.rb
重点看:
external_url 'http://你的IP或域名'
改完执行:
sudo gitlab-ctl reconfigure
重置管理员密码:
sudo gitlab-rails console
user = User.where(id: 1).first
user.password = '新密码'
user.password_confirmation = '新密码'
user.save!
user.locked_at
为空表示未锁定。
查看:
/etc/gitlab/gitlab.rb
LDAP 配置错误会导致无法登录。
systemctl status ssh
cat ~/.ssh/id_rsa.pub
复制到 GitLab → Settings → SSH Keys
git clone ssh://git@ip:端口/xxx.git
sudo gitlab-ctl tail
或只看 Web:
sudo gitlab-ctl tail nginx
登不上 ≠ GitLab 坏了,90% 是:
如果你愿意,可以直接告诉我:
我可以一步步帮你精准排查。