"Host key verification failed" 在 docker alpine 9 构建期间

"Host key verification failed" during docker alpine 9 build

我正在尝试克隆一个私人 git 存储库并 运行 出现此错误:

npm ERR! Host key verification failed.
npm ERR! fatal: Could not read from remote repository.
npm ERR!
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.
npm ERR!
npm ERR! exited with error code: 128

看来我需要将 git 主机添加到 known_hosts 文件中。但是,来自 Docker 的这个版本的 alpine 没有 ~/.ssh/known_host 文件。

存在/etc/ssh/

使用 https 不需要设置 SSH 密钥,也不会要求输入密码:

git clone https://github.com/<username>/<repo name>.git

我必须手动添加主机:

ssh-keyscan -Ht ecdsa >> /root/.ssh/known_hosts


以下评论正确:

您是否尝试添加自己的 known_hosts 文件?例如在 apk add openssh-client 和正在执行 git 操作的任何命令(看起来像用节点启动的东西)之间的某处放置 echo 'git.example.com,192.168.234.100 ssh-rsa theverylongbase64key' >> ~/.ssh/known_hosts 。 – wmorrell 2 月 19 日 23:36 - WMORRELL