Terraform不尊重git的ssh配置

Terraform不尊重git的ssh配置

本文介绍了Terraform不尊重git的ssh配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的terraform模块位于通过ssh密钥访问的私有bitbucket存储库中.

My terraform module is in a private bitbucket repo accessed via an ssh key.

我不知道运行什么git命令terraform或如何更改auth,但似乎正在使用其他ssh配置.

I don't know what git command terraform runs or how to change auth, but it seems to be using a different ssh config.

这是我的 .tf 文件:

module "sdfsdfs" {
  source = "git::ssh://bitbucket.org/mycomp/my-module-root//submodule"
}

我正在jenkins管道中运行它,并且我正在编辑ssh配置以使用特定的密钥.我已经证明这行得通:

I'm running this in a jenkins pipeline and I am editing the ssh config to use a specific key. I have proven this works:

sshagent (credentials: ['my-ssh-key']) {
    bat 'git clone [email protected]:mycomp/my-module.git'
}

ssh配置已正确修改,并在jenkins中使用了我的密钥存储.

The ssh config is modified correctly and uses my key store in jenkins.

我不知道实际上是从git repo中提取什么地形,但是它不尊重ssh的配置:

I don't know what terraform is actually running to pull from git repo but it's not respecting the ssh config:

sshagent (credentials: ['my-ssh-key']) {
    bat 'terraform init'
}

我收到此错误:

C:\Program Files\Git\cmd\git.exe exited with 128: Cloning into
'.terraform\modules\c760b746e09bd59ba86aae13dc9e9959'...

Permission denied (publickey).

fatal: Could not read from remote repository.

terraform在这里做什么或没有做什么?我只想为此会话配置此配置,因此无法为我的jenkins服务器设置全局ssh配置.

What is terraform doing or failing to do here? I want to configure this for this session only, so setting a global ssh config for my jenkins server is not possible.

推荐答案

这部分是位桶限制,部分是我没有阅读文档.

This is partly a bitbucket limitation, partly me not reading the docs thoroughly.

bitbucket api似乎不支持ssh或其他东西,因为terraform文档仅包含带bitbucket的示例https.

The bitbucket api seems to not support ssh or something because, terraform docs only have examples https with bitbucket.

像通用的git repo一样处理它:

Treating this like a generic git repo works:

  source = "git::ssh://[email protected]/mycomp/myrepo.git//my-sub-module"

这篇关于Terraform不尊重git的ssh配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 14:54