2

Setup

There is a host (H1) running gitlab-ce git server within a docker container (C1). The host's OpenSSH server runs on port 22 and provides a host key keyH. The gitlab container provides its own SSH service that is published to host like 10022:22 and provides an own host key keyC.

Problem

On a separate client system, when calling git clone git@H1:10022/<group>/<project> I expect to get connection to the SSH server within container C1. Indeed, I only get connection to host H1 and I get keyH presented (it seems port 22 of the host is used for cloning). Of cause, that leads to a failed clone.

But

Generally (from the same client) pulling and pushing form this dockerized git server works when defining a remote like:

git remote -v
origin  ssh://git@H1:10022/group/project.git (fetch)
origin  ssh://git@H1:10022/group/project.git (push)

So it seems, there is a difference in protocol between ssh://git@H1... and git@H1.... But I think git is communicating via HTTP(S) or SSH, only? What is the difference/problem here?

Platform

  • Ubuntu 14.04.2 (todays upstream patch level)
  • git client 1.9.1
  • gitlab 7.13-stable official Dockerfile
ITL
  • 231
  • 3
  • 9

1 Answers1

2

From git-clone(1):

GIT URLS
...
       The following syntaxes may be used with them:

       o   ssh://[user@]host.xz[:port]/path/to/repo.git/
...
       An alternative scp-like syntax may also be used with the ssh protocol:

       o   [user@]host.xz:path/to/repo.git/

The scp-like syntax doesn't have any way to specify an alternate port. scp supports port selection with the -P option, but that option wasn't carried over into the git tools.

The user@host:path syntax of scp is an imitation of rcp, and rcp predates the web, so it doesn't follow URL conventions. It only coincidentally looks kind of like a schemeless URL.

git@H1:10022/group/project.git specifies the user git on the host H1, and a relative path 10022/group/project.git from that user's home directory.

To access an ssh server on port 10022 you're going to have to use the ssh:// syntax.