[gitlab-CI/CD]--运行报错Host key verification failed

本文档介绍了如何处理在使用GitLab CI/CD时遇到的SSH连接错误,如Host key verification failed和Permission denied。解决方案包括:生成新的SSH密钥对,将私钥作为GitLab项目变量,通过Docker执行器加载私钥,并修改.gitlab-ci.yml文件以添加必要的脚本。通过这些步骤,可以成功部署代码并避免SSH连接错误。
摘要由CSDN通过智能技术生成

最近研究gitlab-CI/CD时,job运行报错,查看日志信息

$ scp code/*.sh root@11.22.33.55:/root/
Host key verification failed.

报错信息或者是“Permission denied, please try again.”

解决方案:
1.参考官方文档,在本地搭建的gitlab的以下路径中找到官方的ssh_keys文档内容
http://11.22.33.44:18080/help/ci/ssh_keys/README.md

How it works(步骤):
1.Create a new SSH key pair locally with ssh-keygen
2.Add the private key as a variable to your project
3.Run the ssh-agent during job to loadthe private key.
4.Copy the public key to the servers you want to have access to (usually in ~/.ssh/authorized_keys) or add it as a deploy key if you are accessing a private GitLab repository.

我们的gitlab-runner是用docker拉起来的,所以主要讲解(SSH keys when using the Docker executor)

实现流程:
1.You will f

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值