(EDIT) This problem was happening also from my laptop using root and my user, which could get the greeting when trying to ssh with git user. Then tried the ansible playbook and it raised errors for the repo too. Tried another one and that clones flawlessly. The problem, then, doesn't seem to be with git, docker or ssh, but with the gitlab configuration.
On a Dockerfile I am trying to clone private repositories hosted on a company server running gitlab and setup with a non standard ssh port.
This is what I expected to run (alongside with some params in ssh config file)
RUN git clone firstname.lastname@example.org:GroupName/repo_name.git
Things I've checked already:
- The repo has a deploy key and it is active.
- Automating with Ansible instead of docker, it can connect and clone repos.
- The key is named id_rsa and it is inside ~/.ssh/
Tried with ssh-agent and seems ok (though I specify the file in the config and shouldn't need it)
Identity added: /opt/.ssh/id_rsa (/opt/.ssh/id_rsa)
The ~/.ssh/config has the following:
Host * StrictHostKeyChecking no PubkeyAcceptedKeyTypes +ssh-rsa PasswordAuthentication no User git ForwardAgent yes Identityfile /opt/.ssh/id_rsa # /opt is the home of the user RUNning the command in docker port 22022
RUNning this from the container:
ssh -vT -i /opt/.ssh/id_rsa email@example.com:GroupName/repo_name.git
Gets the result
Welcome to GitLab, Anonymous!
But the git clone command gets:
Cloning into 'repo_name'... GitLab: The project you were looking for could not be found. fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. The command '/bin/sh -c git clone firstname.lastname@example.org:GroupName/repo_name.git;' returned a non-zero code: 128