使用 rsync 部署 Bitbucket 管道 - 主机密钥验证失败

Gih*_*sha 6 pipeline bitbucket continuous-deployment bitbucket-pipelines

我在存储库下创建了一个 bitbucket 管道,并且生成了 SSH 密钥并更新了主机中的 authorized_keys 文件。交付部分由 rsync 承载,在部署阶段我收到以下错误。

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]
Run Code Online (Sandbox Code Playgroud)

我的 bitbucket-pipelines.yml 如下,

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;
Run Code Online (Sandbox Code Playgroud)

根据文档,这个 yml 应该可以工作,但我遇到了上述错误,非常感谢并欢迎您的帮助。

Jan*_*sen 5

这为我解决了这个问题:

  • 浏览至https://bitbucket.org/your-org/your-app/admin/addon/admin/pipelines/ssh-keys
  • 在已知主机下输入您的应用程序域,说出myapp.com并点击Fetch
  • 等待检索到指纹,然后点击Add

主机地址和指纹将添加到该部分的底部


小智 2

设置 > SSH 密钥

添加您的远程服务器主机/IP 号码,获取并保存指纹。

请参阅步骤 2 https://confluence.atlassian.com/bitbucket/use-ssh-keys-in-bitbucket-pipelines-847452940.html