使用 SSH 将第二个 repo 克隆到 config.yml circleci 时出错

问题描述 投票:0回答:1

我有一个自动化测试存储库,想在进行部署之前将其放入构建步骤中。 但是克隆存储库步骤失败(仅最后一个运行步骤):

automation:
    executor: web-app-executor
    steps:
      - add_ssh_keys:
          fingerprints:
            - '<my_fingerprint>'
      - run:
          name: Trust github ssh
          command: >-
            GIT_SSH_COMMAND='ssh -i ~/.ssh/id_rsa_myfingerprint'
            mkdir -p ~/.ssh
            echo 'github.com ssh-rsa <key>
            bitbucket.org ssh-rsa <key>
            ' >> ~/.ssh/known_hosts
      - run:
          name: Github host
          command: ssh-keyscan -p 443 ssh.github.com >> ~/.ssh/known_hosts
      - run:
          name: Clone automation repository
          command: git clone [email protected]:<Domain>/tests-cypress.git

错误:

#!/bin/bash -eo pipefail
git clone [email protected]:Onyo/tests-cypress.git
Cloning into 'tests-cypress'...
The authenticity of host 'github.com (140.82.113.3)' can't be established.
RSA key fingerprint is SHA256:<finger>.
ssh circleci
1个回答
0
投票

典型的 ssh 准备步骤将涉及设置正确的保护:

# Prepare SSH
mkdir -p .ssh
chmod 700 .ssh
pushd .ssh
touch authorized_keys                               #  Edit to add allowed connections
touch id_rsa                                        #  Edit to add private key
touch id_rsa.pub                                    #  Edit to add public key
chmod 600 authorized_keys
chmod 600 id_rsa
chmod 644 id_rsa.pub
popd

在您的情况下,缺少 chmod,这可能会导致问题(但确切的错误消息会有所帮助)

关于主机身份验证,在此处添加

  ##
  ## Use ssh-keyscan to scan the keys of your private server. Replace gitlab.com
  ## with your own domain name. You can copy and repeat that command if you have
  ## more than one server to connect to.
  ##
  - ssh-keyscan github.com >> ~/.ssh/known_hosts
  - ssh-keyscan bitbucket.org >> ~/.ssh/known_hosts
  - chmod 644 ~/.ssh/known_hosts

2023 年 3 月警告:

"GitHub 已更新其 RSA SSH 主机密钥"


© www.soinside.com 2019 - 2024. All rights reserved.