Make CI Runner clone using SSH, not HTTPS

Hi,

Does anyone know if there is a way to ensure the runner uses SSH for cloning as opposed to HTTPS while the GitLab server is setup for HTTPS? Since I have changed over to HTTPS on the GitLab server it seems the runner automatically tries HTTPS (probably due to the CI URL?).

I have also disabled the proxy, but the result remains the same.

Cloning repository…
Cloning into ‘/home/gitlab-runner/builds/34200655/0/name/project’…
fatal: unable to access ‘https://gitlab-ci-token:xxxxxxxxxxxxxxxxxxxx@gitlab-server/name/project.git/’: Received HTTP code 503 from proxy after CONNECT
ERROR: Build failed: exit status 1

Thank you very much for the assistance!

The error has been resolved (my bad)

But my question still remains… can the runner use the SSH URL as opposed to the HTTPS URL?

Same question here, since we don’t use http git. Are we barking up the wrong tree trying to do everything over port 22? There is so much conflicting and incomplete information in the gitlab docs that I don’t know which end is up. We use no virtualization at all. We just want a runner on the compute cluster talking to the gitlab server on port 22. So far all attempts have failed, and the error I see is about an unsupported key. I get the feeling that really only virtual container runners are really supported.

1 Like

I do not understand your usecase:

  • the runner connects to the GitLab-server via https, so cloning via https should always be possible and is done automatically by the runner itself (at least if you use docker)
  • if you want to do additional clones for n your script, you need to add a valid ssh-key but just using the CI_JOB_TOKEN with https is much easier.

A very old thread, but the problems are still present.

I tried several solutions but all have drawbacks: not efficient, dirty repository, … I started to add this functionality to the Gitlab Runner. But I guess there will be no backport to older versions. Unfortunately I have to use Runner 14.8. So I started a fresh clone at Hapag-Lloyd/Gitlab-Runner.

Feel free to add a MR to enable SSH cloning for other versions as well. Just a few lines of code to enable it and a little bit of configuration in the config.toml:

[runners]
clone_url="ssh://git@my.instance.cloud"
1 Like
Using Docker executor with image python:3.10 ...
Getting source from Git repository  
Fetching changes with git depth set to 20
Reinitialized existing Git repository in /builds/scruel/test-ssh/.git/
error: cannot run ssh: No such file or directory
fatal: unable to fork