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

Bitbucket pipelines | Host key verification failed

Shafee
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 16, 2023

Having an issue with bitbucket pipelines, throwing Host key verification failed.

Bitbucket-pipelines.yml

image: php:7.3.3
pipelines:
  branches:
    development:
      - step:
          name: Deploying in Development
          deployment: development
          caches:
            - node
          script:
            - apt-get update && apt-get install -y openssh-client
            - apt update && apt install -y unzip rsync wget
            - echo "Cloning Project" && ssh -tt $TABACK_SSH_USER@$DEV_SERVER "rm -rf $RELEASE_DIR_TMP && mkdir $RELEASE_DIR_TMP && cd $RELEASE_DIR_TMP && git clone --branch $BITBUCKET_BRANCH https://$REPO_CRED/trustanalytica/react-client.git $RELEASE_DIR_TMP"
            - echo "Copy env file" && ssh -tt $TABACK_SSH_USER@$DEV_SERVER "cp $APP_ROOT/env.$BITBUCKET_BRANCH.client $RELEASE_DIR_TMP/.env"
            - echo "Install Dependencies" && ssh -tt $TABACK_SSH_USER@$DEV_SERVER "cd $RELEASE_DIR_TMP && yarn install"
            - echo "Build" && ssh -tt $TABACK_SSH_USER@$DEV_SERVER "cd $RELEASE_DIR_TMP && yarn build"
            - echo "Deploy" && ssh -tt $TABACK_SSH_USER@$DEV_SERVER "cd $RELEASE_DIR_TMP && ./deploy.sh"

I have the following settings with ssh on the instance.

.ssh/config

Host bitbucket.org
  IdentityFile ~/.ssh/id_rsa
  StrictHostKeyChecking no

I have added my .pub key in authorized_keys and in known_hosts

bitbucket.org,3.136.180.187 ssh-rsa xxxxxxxxxxxxxxxxxxxxxx abc@xxx.com

 

On the bitbucket side, the following are the repository variables

enter image description here

I have also added my server public IP and hostname to Known hosts in bitbucket > repository settings > pipelines > ssh keys -> known hosts.

Please note that the public and private key are generated with ssh-keygen on server itself which are id_rsa and id_rsa.pub, I then copied and pasted the public and private keys to bitbucket > repository settings > pipelines > ssh keys.

The actual exception :

enter image description here

Really don't have any idea what is missing.

1 answer

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 12, 2023

Hi @Shafee and welcome to the community.

  • Is the server you are trying to connect to up and running?
  • Do the directories ~/.ssh and ~/.ssh/authorized_keys on that server have permissions 700 and 600 respectively?

I would suggest modifying the following command in your bitbucket-pipelines.yml file

- echo "Cloning Project" && ssh -tt $TABACK_SSH_USER@$DEV_SERVER "rm -rf $RELEASE_DIR_TMP && mkdir $RELEASE_DIR_TMP && cd $RELEASE_DIR_TMP && git clone --branch $BITBUCKET_BRANCH https://$REPO_CRED/trustanalytica/react-client.git $RELEASE_DIR_TMP"

as follows:

- echo "Cloning Project" && ssh -vvv -o StrictHostKeyChecking=no -tt $TABACK_SSH_USER@$DEV_SERVER "rm -rf $RELEASE_DIR_TMP && mkdir $RELEASE_DIR_TMP && cd $RELEASE_DIR_TMP && git clone --branch $BITBUCKET_BRANCH https://$REPO_CRED/trustanalytica/react-client.git $RELEASE_DIR_TMP"

Temporarily, just for testing purposes. I have added -o StrictHostKeyChecking=no to the ssh command, and also the argument -vvv, which should show more verbose output.

Do you get a successful connection with this command? If not, what is the output of the command? (please mask any private/sensitive info from the output prior to sharing).

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events