Bamboo and git keys issue

I'm getting this error when trying to run a plan that retrieves the code/metadata from a Salesforce instance to a repository on Bitbucket.

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 know that to push changes to a remote repository I need some kind of authentication, right. However, I don't know exactly where and how to set this up on Bamboo. My company is not using Stash or JIRA, just Bitbucket and Bamboo.

I have tried generating a key pair with puttygen and putting the public on Bitbucket, and the private key in the "Shared Credentials" section on Bamboo settings, and it doesn't work.

I have also tried to log into the Bamboo server with the pair provided by Amazon, and generating a pair from inside, using ssh-keygen. It didn't work either.

Where can I specify the key that Bamboo should use with this repo when pushing files? 

2 answers

1 accepted

1 vote
Accepted answer

Hello Renato,

Thank you for your question.

Please, create a Script task with the following example:

# create file
echo "hello, world" > greeting.txt
# add file
git add greeting.txt
# commit
git commit -m "add greeting"
# set url to push
# [username], i.e.: renato
# [password], i.e.: mypassABC
# [account-name], account name where the repository is hosted under
# [repo-slug], given name to the repository
git remote set-url --push origin https://[username]:[password][account-name]/[repo-slug].git
# push to Bitbucket repository
git push origin master
# remove origin
git remote remove origin

The above will let you push files to your repository. Please, notice in the example above it has been used HTTPS protocol instead of SSH. The reason for that is that Bamboo will expect you to type in the password for your SSH key while running the build.

Alternatively, you could create a passphraseless SSH key and replace the origin above to use this key.

If you find this answer useful, I would kindly ask you to accept it so the same will be visible to others who might be facing the same issue you have inquired.

Thank you for your understanding.

Kind regards,
Rafael P. Sperafico
Atlassian Support

Hi Rafael and Renato,

We've ended up solving this problem by changing the dependency URL from SSH to HTTPS, and then specifying the user/pass in the URL using the "//[user]:[pass]" format.

We created a new read-only user with restricted permissions, and used their credentials for this. This has made the build succeed without any further Bamboo-specific configuration needed.

It's not the clean solution we were hoping for, but until Bamboo has support for specifying SSH config in non-checkout tasks, it'll have to do smile


PS. I've removed my previous answer because it was a horrible hack.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 06, 2018 in Bitbucket

Upgrade Best Practices

Hello! My name is Mark Askew and I am a Premier Support Engineer for products Bitbucket Server/Data Center, Fisheye & Crucible. Today, I want to bring the discussion that Jennifer, Matt, and ...

1,905 views 7 10
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you