Issue
I am trying to download several private Python packages with the use of Docker.
I have the following requirements.txt
:
git+ssh://[email protected]/<myorg>/<myrepo1>.git
git+ssh://[email protected]/<myorg>/<myrepo2>.git
and the following 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
However, it seems only key1
is being used and I am stuck with a Please make sure you have the correct access rights
error for the second repo.
The man ssh
page says "It is possible to have multiple -i options (and multiple identities specified in configuration files).
"
How can I source multiple ssh keys to download from different repos on the same host?
Solution
I managed to do this by using an SSH config file:
# 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
And in the Dockerfile:
ENV GIT_SSH_COMMAND="ssh -F ~/.ssh/config"
Answered By - merc1er Answer Checked By - Dawn Plyler (WPSolving Volunteer)