Windows 上的 gitlab-runner 没有获得 .ssh 配置设置

标签 git ssh gitlab continuous-deployment gitlab-ci-runner

我有一个依赖于其他一些 repo 的 repo 。
我正在尝试使用 gitlab-runner 将辅助存储库克隆到 Windows 机器上。
我的 gitlab-ci.yml看起来像这样:

# Deploy to a staging server
deploy_staging:
  stage: deploy
  tags:
    - my_gitlab_runner 
  script:
    - echo "Deploy to staging server"
    - cd C:/
    - git clone git@gitlab.com:test_group/test_ci
  environment:
    name: staging
    url: https://127.0.0.1
  only:
    - master
如果我登录到 windows 框 - 我可以使用 git bash 手动克隆 repos(我已经在 C:/Users/myusername/.ssh 中设置了我的 ssh 设置)
我的 .ssh 配置如下所示:
Host gitlab.com
    Hostname altssh.gitlab.com
    user git
    Port 443
    PreferredAuthentications publickey
    IdentityFile C:/git_keys/my_gitlab_rsa
我必须使用端口 443 - 它在通过 gitbash 进行时可以正常工作。
作业不断失败并出现以下错误:
Cloning into 'test_ci'...
Host key verification failed.
fatal: Could not read from remote repository.
我添加了我的 my_gitlab_rsa.pub作为 deploy_key 到 repo - 它适用于本地克隆 - 只是不通过 gitlab-runner。
我的 gitlab-runner 的 config.toml 如下所示:
[[runners]]
  name = "TestDesktop"
  url = "https://gitlab.com"
  token = "_yt...32fjJb"
  tls-ca-file = "C:/my_certs/my_self_signed_ca.pem"
  executor = "shell"
  shell = "cmd"
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
    [runners.cache.azure]
有任何想法吗?

最佳答案

这只是部分答案,但回答了我提出的问题!
它归结为known_hosts文件。
当我以本地用户身份运行它时,它会要求我验证指纹 - 它会将其添加到 known_hosts文件。
我刚刚复制/粘贴了 known_hosts文件从我的本地用户到系统帐户.ssh目录,然后作业成功而没有问题。
就是说-我不确定自动化的最佳方法-因为我不想每次都必须先以本地用户身份手动运行它才能“接受指纹”-但我想这主要回答了我的问题。

关于Windows 上的 gitlab-runner 没有获得 .ssh 配置设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64436999/

相关文章:

git - 将 ssh key 添加到 Git 帐户

php - 在Mac OS X上从PHP调用 'Host key verification failed.'时,我不断收到 `ssh`

docker - 使用Dockerfile在700(drwx ------)目录中创建文件

docker - 无法向在官方 Docker 容器中运行的 gitlab 发出请求

linux - Jenkins 异常

git - 如何将本地文件夹连接到 Git 存储库并开始在分支上进行更改?

git - 将默认的 Git merge 放入 TFS

git - 如何将 Git 的交互式 rebase 与仅限本地的存储库(无远程/源)一起使用?

git - 无法使用 fig/crane 在 Docker 容器中执行 git 命令

git - 如何在不增加主仓库大小的情况下更新浅克隆子模块