I know this is a commonly asked question, but I couldnt solve it after reading
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.104.22.168' (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 email@example.com:<name>/test.git .test
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?
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 firstname.lastname@example.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. :)
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 email@example.com" 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.
Using the Secured variables will allow you to store the SSH key at a specific location which the ssh-agent can locate.
It will depend on how you want to set up your build. :)
Would you share us the output that you're seeing when you run "ssh -Tv firstname.lastname@example.org" and probably share us the docker image that you're using so that we can test out on our end as well?
Sure! Have a peek at my bitbucket-pipelines.yml
- mkdir -p ~/.ssh
- touch ~/.ssh/known_hosts
- ssh-keyscan -H bitbucket.org >> ~/.ssh/known_hosts
- git clone <xxx> xxx
Just to be clear, I took the public key of repo A (which has this file) and added it as an access key of the other repo (which is private and wish to pull in as 'xxx')
Awesome! Thanks for the information.
While using your docker image, I ran the following command:
- echo $HOME
I notice that the build is running as "root" user but the home directory is "
Based on my understanding of how the issue could happen:
There are two options that we can proceed here:
- mkdir -p /root/.ssh
- mv ~/.ssh/* /root/.ssh/
This should help resolve the issue that you're seeing. :)
Another thing which crosses my mind which you can get it to work by running the build as "move1" user instead of "root".
Override the default user(Section) - Atlassian Documentation
This can be done with the following steps
The above can serve as another workaround for your build :)
Hi All! We’re excited to share the launch of an announcement banner that lets Jira site administrators communicate directly to their users across their Jira Cloud instance. ...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events