【发布时间】:2015-02-22 09:55:40
【问题描述】:
FROM fedora:latest
RUN yum install -y nginx git uwsgi
RUN echo "nameserver 8.8.4.4" > /etc/resolv.conf
RUN rm -rf /root/.ssh/ && mkdir -p /root/.ssh/
COPY id_rsa.pub /root/.ssh/id_rsa.pub
COPY id_rsa /root/.ssh/id_rsa
RUN cat /root/.ssh/id_rsa* && chmod 0400 /root/.ssh/id_rsa && echo "" > /root/.ssh/known_hosts
RUN mkdir -p /srv/nginx/
RUN ssh -vvv -p 49022 git@example.com || true
RUN git config --global user.email "somethingelse@example.com" && git config --global user.name "FunnyBunny"
RUN git clone --depth=1 ssh://git@example.com:port/repo.git /srv/nginx/repo
RUN chown -Rf nginx:nginx /srv/nginx
RUN rm -rf /root/.ssh/
USER nginx
EXPOSE 8080
CMD ["/usr/sbin/nginx"]
我将公共 ssh id_rsa.pub 添加到另一个 docker 容器中同一主机上的 gitolite 存储库中。不好的是克隆总是失败。
Cloning into '/srv/nginx/repo'...
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
虽然 ping 工作正常。
ssh -vvv 行以
Host key verification failed.
另一方面,将公钥和私钥导入fedora:latest 并只运行git clone --depth ...,就可以了!
我真的很困惑如何解决这个问题。
CoreOS 版本 557.2.0
这不会产生可行的解决方案:Using SSH keys inside docker container
【问题讨论】:
-
“我将公共 ssh
id_rsa添加到我的 gitolite 存储库中”:您的意思是id_rsa.pub吗?因为.pub是公钥。当你把它放在gitolite/keys folder中时,你给它取了什么名字id_rsa.pub? -
Ye pub ofc,相应地解决了这个问题。公钥在 gitolite 中的名称根本不重要,如果我错了,请纠正我。
-
公钥的名称(如
gitolite/keys中所写)至关重要:请参阅我的旧答案stackoverflow.com/a/13320256/6309 和官方文档gitolite.com/gitolite/… -
是否需要在 CoreOS 上禁用 StrictHostKeyChecking ?
-
@VonC 只要 pubkey 名称和配置一致(在我的情况下两者都称为“puller”)gitolite 应该可以正常工作,无论使用什么 git 用户名。