ssh - 使用 SSH 将第二个 repo 克隆到 config.yml circleci 时出错
问题描述
我有一个自动化测试存储库,并希望在进行部署之前将其放入构建步骤中。但是克隆存储库步骤失败(仅最后一个运行步骤):
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 git@github.com:<Domain>/tests-cypress.git
错误:
#!/bin/bash -eo pipefail
git clone git@github.com: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 准备步骤将涉及设置正确的保护:
# 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
推荐阅读
- python - 没有偏移符号的 Matplotlib 颜色条
- python - QStyledItemDelegate:添加禁用检查指示器
- jestjs - 排毒失败并显示“找不到模块 'jest-cli/build/cli/args'”
- r - 如何使用环境变量执行 dplyr 连接
- javascript - 在具有首字母缩写词支持的连接大写单词之间插入空格
- spring - Spring @Transactional Isolation 级别覆盖策略解释
- mysql - MySql分层查询
- flutter - 在 Flutter 中无法改变 ListView 中 DropDown Menu 的状态
- c - 为什么我收到错误“kernel/drivers/screen.c:7:22: error: invalid initializer char* string[] = message;”
- javascript - 如何将axios请求中的参数变成对象?