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
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 :
Really don't have any idea what is missing.
Hi @Shafee and welcome to the community.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.