Bitbucket pipelines | Host key verification failed
Asked by Shafee:

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

Bitbucket-pipelines.yml

    image: php:7.3.3pipelines:  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](https://i.stack.imgur.com/lBk5D.png)](https://i.stack.imgur.com/lBk5D.png)

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](https://i.stack.imgur.com/IMiKn.png)](https://i.stack.imgur.com/IMiKn.png)

*Really don't have any idea what is missing.*


Answers:
author: Theodora Boudale
body: Hi [@Shafee](/t5/user/viewprofilepage/user-id/5171821) 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


Tags: bitbucket-cloud

cloud