【发布时间】:2026-02-06 06:55:02
【问题描述】:
我有一个通过 docker-compose 运行的 gitlab ce 映像
gitlab:
image: 'gitlab/gitlab-ce:latest'
restart: always
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'https://gitlab.theboohers.org'
# Add any other gitlab.rb configuration here, each on its own line
ports:
- '8000:80'
- '8001:443'
- '22:22'
volumes:
- '$GITLAB_HOME/config:/etc/gitlab'
- '$GITLAB_HOME/logs:/var/log/gitlab'
- '$GITLAB_HOME/data:/var/opt/gitlab'
networks:
- app-network
我可以通过 https 登录(使用 nginx 代理),但我无法通过 ssh 进行身份验证。
我确认端口 22 正在监听:
nc -vz gitlab.theboohers.org 22
Connection to gitlab.theboohers.org (194.195.222.5) 22 port [tcp/ssh] succeeded!
在详细输出中,我看到提供了密钥:debug1: Offering public key: /home/deploy/.ssh/id_rsa RSA SHA256
但我遇到了错误:
git@gitlab.theboohers.org: Permission denied (publickey).
完整详细的 ssh 连接:https://gist.github.com/tbbooher/336e1bb277456efde6003111a56f3118
【问题讨论】:
-
您是否使用相同的端口通过 SSH 连接到主机?可能您的密钥仅在容器
authorized_keys中(因为您是通过 webui 添加的),但不在实际主机上。我建议您为主机 SSH 和 gitlab SSH 使用不同的端口。 -
我会检查的。他们可能是问题所在。
-
你是正确的。
标签: docker nginx gitlab openssh