Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

SSH connection Hosting server to Bitbucket : Host key verification failed.


I keeping gettting host verification failed. I am unclear what username to use before the at symbol? Do I need to use my custom username or bitbucket or git?

I followed this guide here:


  • I generated a new key.
  • copied the public key to my server's authorized keys file
  • added the known hosts based on my server's domain

I am not sure why it does not work. Here is my pipeline:


# This is a sample build configuration for PHP.
# Check our guides at for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.

image: ubuntu:16.04

custom: #deploy to live site deploy:
step: name: deploy
apt-get update -y
apt-get install -y ssh
ssh ~/


1 answer

1 accepted

3 votes
Answer accepted
mwatson Atlassian Team Jul 04, 2018

The error "Host Key verification Failed" relates to the known_host file entry you have, not the user you are supplying - it indicates that the known_hosts entry you added in step 2 from is no longer the same as the key that is being retrieved when your script tries to ssh - see the answer in

I would remove the known_hosts entry in the pipelines admin ui and re-add the entry for the server you are trying to contact ( in the example above)

Hope this helps

Yes, thank you, I had to add the non www record.



Thanks Matthew, it worked for me.. I hadn't added ip of my remote machine in known hosts at

Like DigitalDrive likes this

I am getting the same problem and have tried removing the record multiple times and re-adding it. The same host works on a different repo but is always failing.

mwatson Atlassian Team Dec 05, 2018

Hey Matt, are you saying that ssh-ing to the same host works in one repository but not in another? Does it have the same known hosts fingerprint in each repository?

Yes, I have two repos that I deploy to the same host. I successfully set up the first one but the second isn't working. The fingerprint is exactly the same on both and doesn't change when I delete and re-add to known hosts.

mwatson Atlassian Team Dec 06, 2018

Weird - could it be possible that you have something in your repo or build script that overrides the ~/.ssh/known_hosts file? The fingerprints you add in the pipelines admin section are added first so could be removed/overridden by anything that gets added later...

Hey, here is the pipelines configuration. Just calling a deploy script to checkout the correct commit on the server.  I don't see anything that should affect the known-hosts. 

- step:
name: Deploy to Staging
deployment: staging
max-time: 1
- cat | ssh ${GCLOUD_USER}@${STAGING_HOST} bash -s - ${BITBUCKET_COMMIT}


mwatson Atlassian Team Dec 09, 2018

Doesn't look like there's anything in there that should cause a problem  - if this is still happening you might want to open a support request at  so our support engineers can look into the specifics of your repos for more information.

Like # people like this

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bitbucket Pipelines

Bitbucket Pipelines Runners is now in open beta

We are excited to announce the open beta program for self-hosted runners. Bitbucket Pipelines Runners is available to everyone. Please try it and let us know your feedback. If you have any issue...

3,871 views 68 21
Read article

Community Events

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

Events near you