[英]How do we set StrictHostKeyChecking=no for npm when running in docker container using jenkins pipeline?
I am trying to install npm
modules from private repository in docker container from a jenkins pipeline .我正在尝试从jenkins 管道的 docker 容器中的私有存储库安装
npm
模块。 I have followed this blog: https://sanderknape.com/2019/06/installing-private-git-repositories-npm-install-docker/ and used the docker buildkit option.我关注了这个博客: https://sanderknape.com/2019/06/installing-private-git-repositories-npm-install-docker/并使用了 docker buildkit 选项。 My problem is in the ssh configuration for
StrictHostKeyChecking=no
.我的问题出在
StrictHostKeyChecking=no
的 ssh 配置中。
When I run this command in docker it is successful as it adds the host to known_hosts当我在 docker 中运行此命令时,它会成功,因为它将主机添加到 known_hosts
RUN --mount=type=ssh,id=github GIT_SSH_COMMAND="ssh -vvvT -o StrictHostKeyChecking=no" git clone git@github.****
But while running this command, I get Host Verification failed error:但是在运行此命令时,出现主机验证失败错误:
RUN --mount=type=ssh,id=github GIT_SSH_COMMAND="ssh -vvvT -o StrictHostKeyChecking=no" npm install git+ssh://git@github.****
Also, how do we pass ssh-agent configured in jenkins pipeline to a docker container?另外,我们如何将 jenkins 管道中配置的 ssh-agent 传递给 docker 容器?
Got it resolved at last.终于解决了。 The problem was that git and npm were using different home directories for cloning.
问题是 git 和 npm 使用不同的主目录进行克隆。
Git was using root user and so had permission to check the /root/.ssh folder but somehow npm was using the directory /home/user/.ssh and was getting some permission related problems. Git 使用 root 用户,因此有权检查 /root/.ssh 文件夹,但不知何故 npm 使用目录 /home/user/.ssh 并遇到一些与权限相关的问题。
After doing a simple做了一个简单的之后
RUN npm config set cache /root
I was able to successfully execute the below command without any problems.我能够毫无问题地成功执行以下命令。
RUN --mount=type=ssh,id=github GIT_SSH_COMMAND="ssh -vvvT -o StrictHostKeyChecking=no" npm install git+ssh://git@github.****
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.