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

Terraform doesn't obey conditional git config for github ssh #31254

Closed
ghost opened this issue Jun 16, 2022 · 3 comments
Closed

Terraform doesn't obey conditional git config for github ssh #31254

ghost opened this issue Jun 16, 2022 · 3 comments
Labels
bug new new issue not yet triaged

Comments

@ghost
Copy link

ghost commented Jun 16, 2022

This issue was opened from my professional account by mistake.
Please visit the clone: #31255

Cloning an enterprise github repo with ssh that is part of a conditional config ends with git@github.com: Permission denied (publickey).

##Git config - main

[includeIf "gitdir/i:C:/XXX/Repos/"]
    path = C:\\XXX\\.gitconfig

##Git config - C:\XXX\.gitconfig

[core]
sshCommand = "ssh -i c:\\\\XXX\\\\.ssh\\\\XXX.pkey"

Running git pull works correctly:

> git pull
Enter passphrase for key 'c:\XXX\pkey':xxxxxx
...pulling... 

Running terraform init:

Downloading git::ssh://git@github.com/XXXXXX?ref=v1.0.0 for tags...
╷
│ Error: Failed to download module
│
│ Could not download module "X" (tags.tf:1) source code from "git::ssh://git@github.com/XXXXX.git":      
│ error downloading 'ssh://git@github.com/XXXXX': C:\Program Files\Git\cmd\git.exe exited with 128:     
│ Cloning into '.terraform\modules\X'...
│ git@github.com: Permission denied (publickey).
│ fatal: Could not read from remote repository.
│
│ Please make sure you have the correct access rights
│ and the repository exists.

Terraform Version

Terraform v1.2.3
on windows_amd64

Steps to Reproduce

  1. Setup gitconfig with conditionally load the a config from a specific path
  2. Setup the conditional gitconfig with the key file
  3. Run terraform init

References

Additional Info

I ve tried the ssh config file and it works, but this way I have only one key for all github projects.
SSH config that worked:

Host github.com
   HostName github.com
   PreferredAuthentications publickey
   IdentityFile ~/.ssh/id_rsa_hub
@ghost ghost added bug new new issue not yet triaged labels Jun 16, 2022
@ghost ghost changed the title Terraform doesn't doest obey conditional git config Terraform doesn't obey conditional git config for github ssh Jun 16, 2022
@ghost
Copy link
Author

ghost commented Jun 16, 2022

This issue was opened from my professional account by mistake.
Please visit the clone of this: #31255

@ghost ghost closed this as completed Jun 16, 2022
@georgekosmidis
Copy link

Just adding another relevant issue, which didnt work for me:
hashicorp/terraform-google-vault#45

@github-actions
Copy link

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 Jul 17, 2022
This issue was closed.
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
Projects
None yet
Development

No branches or pull requests

1 participant