Gihan Dilusha
Gihan Dilusha

Reputation: 921

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.

Upvotes: 8

Views: 4424

Answers (2)

Jannie Theunissen
Jannie Theunissen

Reputation: 30164

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

Upvotes: 5

Gabriel Novaes
Gabriel Novaes

Reputation: 192

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

Upvotes: 2

Related Questions