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: https://confluence.atlassian.com/bitbucket/use-ssh-keys-in-bitbucket-pipelines-847452940.html

 

  • 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 https://confluence.atlassian.com/x/e8YWN 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

pipelines:
custom: #deploy to live site deploy:
-
step: name: deploy
script:
-
apt-get update -y
-
apt-get install -y ssh
-
ssh whataccountnamegoeshere@mydomainname.com ~/deploy.sh

 

1 answer

1 accepted

2 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 https://confluence.atlassian.com/bitbucket/use-ssh-keys-in-bitbucket-pipelines-847452940.html is no longer the same as the key that is being retrieved when your script tries to ssh - see the answer in https://askubuntu.com/questions/45679/ssh-connection-problem-with-host-key-verification-failed-error

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 (mydomainname.com in the example above)

Hope this helps

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

 

Thanks,
Brian

Thanks Matthew, it worked for me.. I hadn't added ip of my remote machine in known hosts at https://bitbucket.org/../../admin/addon/admin/pipelines/ssh-keys

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. 

pipelines:
branches:
master:
- step:
name: Deploy to Staging
deployment: staging
max-time: 1
script:
- cat stage-deploy.sh | 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 https://support.atlassian.com/contact/#/  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

What We Learned When We Researched Open Source Vulnerabilities in 7 Popular Coding Languages

...hey are a part of us, shaping how we interact with the world around us. The same holds true for programming languages when we think about how different kinds of vulnerabilities raise their heads in t...

154 views 0 1
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