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

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

brianbarthold July 3, 2018

 

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

3 votes
Answer accepted
mwatson
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 4, 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

brianbarthold July 5, 2018

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

 

Thanks,
Brian

Deleted user October 3, 2018

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

Like DigitalDrive likes this
Matt Goodson December 4, 2018

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
Atlassian Team members are employees working across the company in a wide variety of roles.
December 5, 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?

Matt Goodson December 6, 2018

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
Atlassian Team members are employees working across the company in a wide variety of roles.
December 6, 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...

Matt Goodson December 9, 2018

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
Atlassian Team members are employees working across the company in a wide variety of roles.
December 9, 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
TAGS
AUG Leaders

Atlassian Community Events