Is there a preferred way to clone a private git repo? All my attempts to get this to work so far are failing.
I am copying a private key in to my container and attempting to use it to clone a private repo. I can clone the repo manually if I log in to the container and accept the RSA fingerprint.
This is always failing when I attempt to automate the pulling of the private repo, I have tried tried adding to disable strict host key checking by adding a config in /root/.ssh/config. I have tried other various configs in the ssh_config but haven't had any luck.
Here is the message I am seeing.
Step 7 : RUN git clone [email protected]:mycoolrepo.git /opt/repo
---> Running in de83ebb98ee9
Cloning into '/opt/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.
The line in the Dockerfile looks like this:
COPY id_rsa /root/.ssh/id_rsa
RUN chmod 600 /root/.ssh/id_rsa && echo "Host github.com\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config
This method is working for other distros. How can I get the key to automatically get accepted?
As a note, I am able to copy an existing known_hosts file in to the image and it works.
Got it. I had to add the following to the Dockerfile.
RUN ssh-keyscan github.com >> ~/.ssh/known_hosts
Can you share complete DockerFile?
Most helpful comment
Got it. I had to add the following to the Dockerfile.
RUN ssh-keyscan github.com >> ~/.ssh/known_hosts