(编辑)这个问题也发生在我的笔记本电脑使用根和我的用户,这可能会得到问候,当试图用SSH用户。 然后尝试了一下这个可靠的手册,它也提出了回购的错误。 试过另一个,克隆完美无瑕。 这个问题似乎并不是用git,docker或者ssh,而是用gitlabconfiguration。
在一个Dockerfile上,我正在尝试运行gitlab的公司服务器上托pipe的私有存储库,并使用非标准的ssh端口进行设置 。
这是我期望运行(在sshconfiguration文件中的一些参数旁边)
RUN git clone [email protected]:GroupName/repo_name.git
我已经检查过的东西:
试过用ssh-agent,似乎没问题(虽然我在configuration文件中指定,不需要它)
Identity added: /opt/.ssh/id_rsa (/opt/.ssh/id_rsa)
〜/ .ssh / config具有以下内容:
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
从容器中运行这个:
ssh -vT -i /opt/.ssh/id_rsa [email protected]:GroupName/repo_name.git
获取结果
欢迎来到匿名的GitLab!
但是git clone命令会得到:
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 [email protected]:GroupName/repo_name.git;' returned a non-zero code: 128
~/.ssh/config在哪里? Docker的构build是以root身份完成的,所以configuration需要在/root/.ssh/config