无法通过 SSH 进入 Gitlab

Can't SSH into Gitlab

我有一个 gitlab ce 镜像 运行 通过 docker-compose

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 已被使用,我必须设置另一个。