我正在尝试使用Docker下载几个私有Python包。
我有以下requirements.txt
:
git+ssh://git@github.com/<myorg>/<myrepo1>.git
git+ssh://git@github.com/<myorg>/<myrepo2>.git
和以下Dockerfile
:
...
RUN ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts && chmod 600 ~/.ssh/
ENV GIT_SSH_COMMAND="ssh -i ~/.ssh/key1 -i ~/.ssh/key2"
RUN pip install -r requirements.txt
然而,似乎只有key1
被使用,我被困在第二个repo的Please make sure you have the correct access rights
错误。
man ssh
页面显示"It is possible to have multiple -i options (and multiple identities specified in configuration files).
">
我如何从同一主机上的不同仓库下载多个ssh密钥?
我通过使用SSH配置文件做到了这一点:
# Repo 1
Host github.com-repo-1
HostName github.com
IdentityFile ~/.ssh/repo-1
# Repo 2
Host github.com-repo-2
HostName github.com
IdentityFile ~/.ssh/repo-2
在Dockerfile中:
ENV GIT_SSH_COMMAND="ssh -F ~/.ssh/config"