Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 1.6.0 - Host Key Verification Failed when using git ssh #33986

Closed
1BuBuBu1 opened this issue Oct 5, 2023 · 8 comments · Fixed by #34045
Closed

Version 1.6.0 - Host Key Verification Failed when using git ssh #33986

1BuBuBu1 opened this issue Oct 5, 2023 · 8 comments · Fixed by #34045
Labels
bug new new issue not yet triaged v1.6 Issues (primarily bugs) reported against v1.6 releases waiting-response An issue/pull request is waiting for a response from the community

Comments

@1BuBuBu1
Copy link

1BuBuBu1 commented Oct 5, 2023

Terraform Version

Terraform v1.6.0

Terraform Configuration Files

module "XXXXXXXXXX" {
  source = "git@example.com:site/module.git"
  name   = "XXXXXXXXXX"
}

Debug Output

Initializing modules...
2023-10-05T07:42:44.101Z [TRACE] ModuleInstaller: installing child modules for . into .terraform/modules
2023-10-05T07:42:44.115Z [DEBUG] Module installer: begin XXXXXXXXXX
2023-10-05T07:42:44.115Z [TRACE] ModuleInstaller: XXXXXXXXXX is not yet installed
2023-10-05T07:42:44.115Z [TRACE] ModuleInstaller: cleaning directory .terraform/modules/XXXXXXXXXX prior to install of XXXXXXXXXX
2023-10-05T07:42:44.115Z [TRACE] ModuleInstaller: XXXXXXXXXX address "git::ssh://git@example.com/site/module.git" will be handled by go-getter
Downloading git::ssh://git@example.com/site/module.git for XXXXXXXXXX...
2023-10-05T07:42:44.115Z [TRACE] getmodules: fetching "git::ssh://git@example.com/site/module.git" to ".terraform/modules/XXXXXXXXXX"
2023-10-05T07:42:44.178Z [DEBUG] Module installer: begin XXXXXXXXXX
2023-10-05T07:42:44.178Z [TRACE] ModuleInstaller: XXXXXXXXXX is not yet installed
2023-10-05T07:42:44.178Z [TRACE] ModuleInstaller: cleaning directory .terraform/modules/XXXXXXXXXX prior to install of XXXXXXXXXX
2023-10-05T07:42:44.178Z [TRACE] ModuleInstaller: XXXXXXXXXX address "git::ssh://git@example.com/site/module.git" will be handled by go-getter
Downloading git::ssh://git@example.com/site/module.git for XXXXXXXXXX...
2023-10-05T07:42:44.179Z [TRACE] getmodules: fetching "git::ssh://git@example.com/site/module.git" to ".terraform/modules/XXXXXXXXXX"

Expected Behavior

Terraform Init should execute successfully and download the necessary modules from the private repository through git ssh.

Actual Behavior

SSH Keys were not modified and still active, but terraform init returned with "could not read from remote repository"

│ Error: Failed to download module
│ 
│   on XXXXX.tf line XX:
│   XX: module "XXXXXXX" {
│ 
│ Could not download module "XXXXXXX"
│ (XXXXXXX.tf:XX) source code from
│ "git::ssh://git@example.com/site/module.git":
│ error downloading
│ 'ssh://git@example.com/site/module.git':
│ /usr/bin/git exited with 128: Cloning into
│ '.terraform/modules/XXXXXXX'...
│ Host key verification failed.
│ fatal: Could not read from remote repository.
│ 
│ Please make sure you have the correct access rights
│ and the repository exists.

Steps to Reproduce

  1. terraform init

Additional Context

Rollbacked version to terraform v1.5.7 with all config staying intact, no changes introduced to all config files. the terraform init command can be executed successfully and modules have been installed as expected. Using v1.6.0 will result in the above mentioned issue.

References

No response

@1BuBuBu1 1BuBuBu1 added bug new new issue not yet triaged labels Oct 5, 2023
@jbardin
Copy link
Member

jbardin commented Oct 5, 2023

Hi @1BuBuBu1,

Thanks for filing the issue. Are you by chance using GIT_SSH_COMMAND to add options to the cli, which would make this a duplicate of #33985? Fetching a source from a git repository is handled by the git command, and mostly outside of Terraform's control.

Thanks!

@jbardin jbardin added the waiting-response An issue/pull request is waiting for a response from the community label Oct 5, 2023
@apparentlymart apparentlymart added the v1.6 Issues (primarily bugs) reported against v1.6 releases label Oct 5, 2023
@falimov
Copy link

falimov commented Oct 5, 2023

Having the same issue. Using Terraform Cloud and don't believe we use GIT_SSH_COMMAND.

@1BuBuBu1
Copy link
Author

1BuBuBu1 commented Oct 6, 2023

Hi @1BuBuBu1,

Thanks for filing the issue. Are you by chance using GIT_SSH_COMMAND to add options to the cli, which would make this a duplicate of #33985? Fetching a source from a git repository is handled by the git command, and mostly outside of Terraform's control.

Thanks!

Hey @jbardin . Yes tried with the GIT_SSH_COMMAND by supplying the path of SSH key
export GIT_SSH_COMMAND="ssh -i /home/user/.ssh/key"
Above works on version v1.5.7 but when trying on v1.6.0 it does not.

Add-on for Terraform Cloud, since the terraform version was set on "latest", when v1.6.0 was release, the workspace failed to be planned with the same error, had to roll it back to v1.5.7 for it to work.

Regards.

@apparentlymart
Copy link
Contributor

Terraform Cloud's execution environment uses GIT_SSH_COMMAND internally (as an implementation detail) to disable known-hosts checking when cloning modules, and so I suspect the failures in Terraform Cloud are the same problem, just hidden behind an extra layer of abstraction.

@sgp-nwarden
Copy link

+1 seeing this issue with Terraform Cloud workspaces using "latest" for Terraform version. Rollback to 1.5.7 fixes

@vdevcicinf

This comment was marked as duplicate.

@Nirrleybo

This comment was marked as duplicate.

Copy link
Contributor

github-actions bot commented Dec 8, 2023

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug new new issue not yet triaged v1.6 Issues (primarily bugs) reported against v1.6 releases waiting-response An issue/pull request is waiting for a response from the community
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants