docker - 无法通过 SSH 连接到 Gitlab
问题描述
我有一个通过 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 连接,我必须在 GITLAB_OMNIBUS_CONFIG 环境变量中添加以下行:
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'https://${GITLAB_HOST}'
# ...
gitlab_rails['gitlab_shell_ssh_port'] = ${SSH_PORT}
并打开端口(如您所愿):
ports:
- ${SSH_PORT}:22
之后,我可以使用以下网址克隆存储库:
git clone ssh://git@${GITLAB_HOST}:${SSH_PORT}/${REPOSITORY}.git
请注意,端口 22 已被使用,我必须设置另一个。
推荐阅读
- asp.net-web-api - 面临问题 Razor 重定向页面 400 错误 rss
- deep-learning - 使用深度学习以图像格式提取文本字段?
- amazon-web-services - 调用公共 apigateway url 时 VPC 中的 Lambda 超时
- kotlin - Kotlin:平台类 java.sql.Timestamp 需要显式注册 JsonAdapter
- python - DF 中的值基于来自另一个 DF 的值和条件
- c# - 有没有办法在没有 WPF 或 Visual Studio 的情况下在 C# 中制作 GUI(仅使用代码)?
- php - 新鲜 Laravel 7 项目 LEMP 后出现 502 错误网关
- node.js - 在 Nodejs 中,为什么缓冲区表示会根据字符编码而改变?
- java - Thrift 编译器生成 IllegalArgument 错误
- flutter - 异步等待 Navigator.push() - 出现 linter 警告:use_build_context_synchronously