Reputation: 727
I have a docker container whose job it is to push a file to a git repository.
It refuses to connect to the git repository with the error.
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I have tried adding my known_hosts file (which pushes and pulls from the git repo just fine) to the docker using
RUN mkdir ~/.ssh
ADD known_hosts ~/.ssh/known_hosts
But still get the same error. ssh-keygen returns no output, and
'GIT_SSH_COMMAND="ssh -o \'UserKnownHostsFile=/dev/null\' -i ./ssh_id" git push origin master'
didn't fix it either. How can I disable host key verification so that I stop seeing this error?
Upvotes: 2
Views: 11850
Reputation: 1323793
Adding known_hosts
is not enough.
You would need to add as well ~/.ssh/id_rsa
to your docker image in order for an ssh connection to have a chance to succeed.
And you need to make sure everything is in 600
mode (or ssh would refuse to consider that private key): see "Git SSH authentication".
Try a RUN ssh -Tv [email protected]
just for testing: that will show you if the known_host
or the key are the problem here.
Upvotes: 9