Hi!I know this is a commonly asked question, but I couldnt solve it after reading
https://confluence.atlassian.com/bitbucket/use-ssh-keys-in-bitbucket-pipelines-847452940.html
https://community.atlassian.com/t5/Bitbucket-questions/quot-Warning-Permanently-added-the-RSA-host-key-for-IP-address/qaq-p/28906
https://community.atlassian.com/t5/Bitbucket-questions/How-can-I-use-SSH-in-Bitbucket-Pipelines/qaq-p/347345
So, I kind of need someone to point out to me where I went wrong.What I need:In Repo A, I am pulling Repo B. (Both are in the same team)
I have generated an SSH key in Repo A and copied over the public key as an Access key of Repo B.On an pipeline run, this is the error i get.
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 added my personal key and tried it out on my computer and I get prompted
Warning: Permanently added 'bitbucket.org,18.205.93.0' (RSA) to the list of known hosts.
Not sure if that's the issue.
Here is the step i have in bitbucket-pipelines.yml
git clone git@bitbucket.org:<name>/test.git .test
Hi Ryan,
Hope you're doing well. The `Host key verification failed` error that you're seeing indicates that the ssh-agent in the build unable to recognize bitbucket.org fingerprint.
AFAIK, bitbucket.org's fingerprint will be added to the build by default unless there's custom configuration within the docker image that you're using.
Nonetheless, would you try the following workarounds and let us know how it goes?
Regards,Ronald
Hey RonC,
I've added bitbucket.org to Known Hosts for both repos and it dosent seem to work.
Testing with atlassian/default-image:latest, got the repo cloned at the very least. I guess the only option I have left would be to build a docker in docker?
Hey Ryan,
If you need that docker image, another workaround is to run the following command to add the Host key manually:
ssh-keyscan -H bitbucket.org >> ~/.ssh/known_hosts
You may want to run "ssh -Tv git@bitbucket.org" to double-check the path to the known_hosts file that your image's ssh is using.
If it's not in "~/.ssh/known_hosts", you may need to change the command:
ssh-keyscan -H bitbucket.org >> /path/to/known_hosts
Hope this helps.
Hi Ron,I just checked it out, in the docker, I have ssh but have not ran ssh-keygen so I have no known_hosts file anywhere. (verified with a `find / -name "known_hosts"`) or a ~/.ssh for that matter.I am not familiar with good docker practices but it seems like a bad idea to have an ssh key in a docker image (unless someone could advice me otherwise)
What I tried was have the creation of ~/.ssh/known_hosts done in steps of the bitbucket-pipelines.yml before the clone and did as advised.
First, the command "ssh -Tv git@bitbucket.org" always gave an error. It needed a user input confirmation and even on my computer it failed.
Second, since I know where my known_hosts file is, I just proceeded with adding the keyscan but the clone ultimately failed.
Hey Ronald,
Thanks alot for your help. All works now.
It looks like you're new here. Sign in or register to get started.