I am using AWS ec2 instance as private git repository. This instance is also used for running Dockerfile and docker file tries to checkout code from this private repository. My basic setup is done as per https://alvinabad.wordpress.com/2013/03/23/how-to-specify-an-ssh-key-file-with-the-git-command/ option 2. However, when i am running my docker build command:
$ sudo docker build -t "spring-petclinic" .
The build script stops at line:
RUN /root/.ssh/git.sh -i /root/.ssh/.pem clone [email protected]:/usr/local/git-repos/spring-petclinic.git
and gets following error:
"Cloning into 'spring-petclinic'... 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 search through google for this type of error, on similar kind of setup, but unable to search for.
Please help!!!
Thanks
To fix this error, we need to delete the offending key from the “known_hosts” file present in our system in “. ssh” directory. The error gives you the remote server's IP address and the line number on which the key is stored in the “known_hosts” file.
The Git “fatal: Could not read from remote repository” error occurs when there is an issue authenticating with a Git repository. This is common if you have incorrectly set up SSH authentication. To solve this error, make sure your SSH key is in your keychain and you connecting to a repository using the correct URL.
The problem that you're seeing is that it's connecting for the first time to an unknown host and SSH plays it safe by default. If you were running the command interactively, you'd get prompted to add the key to your known_hosts file.
You can either add the host key to the known_hosts
file (better) or set StrictHostKeyChecking
to no
in the ssh config (worse).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With