Search code examples
gitsshopenshiftokds2i

Openshift 3.11 source-to-image (s2i) build using no standard ssh port


I'm trying to use OpenShift s2i builds to build an image, pulling source code from a git repo on a non standard port (port 222).

I thought this would be as simple as specifying the port in the git repo url, however this doesnt seem to work. When I run this, I get the following:

Cloning "git@ssh.gitlab.intnerldomain.com:222/myorg/myproject.git" ...
WARNING: timed out waiting for git server, will wait 1m4s
error: ssh: connect to host ssh.gitlab.intnerldomain.com port 22: Connection timed out
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Note that the git url contains :222 but the error message state it is using port 22.

How can I tell Openshift, and in particular, source-to-image, to use a custom port?


Solution

  • To use a port in an ssh URL in Git, use ssh://user@host:port/path/to/repo.git syntax. The shorthand user@host:path syntax does not allow port insertion. The URL you used is the equivalent of:

    ssh://git@ssh.gitlab.intnerldomain.com/222/myorg/myproject.git