Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bitbucket pipline deploy with rsync - Host key verification failed

I have created a bitbucket pipeline under a repository and i have generated the SSH Keys and have updated the authorized_keys file in the host. Delivery part is carried by rsync, during the deployment phase i'm getting the following error.

rsync -zrSlh --stats --exclude-from=deployment-exclude-list.txt $BITBUCKET_CLONE_DIR/ $DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_PATH;
Host key verification failed.
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(235) [sender=3.1.2]

My bitbucket-pipelines.yml as follows,

image: php:7.2.1-fpm

pipelines:
  default:
    - step:
        caches:
          - composer
        script:
          - apt-get update
          - apt-get install git -y
          - export APP_ENV=testing
          - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
          - composer install
    - step:
            name: Deploy to test
            deployment: test
            script:
              - apt-get update
              - apt-get install ssh -y
              - apt-get install rsync -y
              - rsync -zrSlh --stats --exclude-from=deployment-exclude-list.txt $BITBUCKET_CLONE_DIR/ $DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_PATH;

According to the documentation this yml should work, but i'm getting above error, your help is really appreciated and welcome.

like image 308
Gihan Dilusha Avatar asked May 07 '19 11:05

Gihan Dilusha


2 Answers

This solved it for me:

  • Browse to https://bitbucket.org/your-org/your-app/admin/addon/admin/pipelines/ssh-keys
  • Under Known hosts enter your app domain, say myapp.com and tap Fetch
  • Wait for the fingerprint to be retrieved and then tap Add

The host address and fingerprint will be added to the bottom of the section

like image 62
Jannie Theunissen Avatar answered Nov 16 '22 20:11

Jannie Theunissen


Settings > Ssh Key

Add your remote server host/ip number, fetch and save the fingerprint.

See the step 2 https://confluence.atlassian.com/bitbucket/use-ssh-keys-in-bitbucket-pipelines-847452940.html

like image 44
Gabriel Novaes Avatar answered Nov 16 '22 20:11

Gabriel Novaes