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

GitHub SSH failure due to insteadOf git configuration #874

Open
3 tasks done
nyurik opened this issue Feb 20, 2023 · 1 comment
Open
3 tasks done

GitHub SSH failure due to insteadOf git configuration #874

nyurik opened this issue Feb 20, 2023 · 1 comment

Comments

@nyurik
Copy link

nyurik commented Feb 20, 2023

Describe the bug
If a user has automatic git redirect from https to ssh, cargo generate fails with the invalid or unknown remote ssh hostkey error.

make sure you

  • I'm on the latest rust version rustup update
  • I'm on the latest cargo-generate version cargo install cargo-generate
  • In case you have an own .gitconfig, provide all sections that contains one of: insteadOf, url

To Reproduce

  • In ~/.gitconfig (on Linux), add this section:
[url "ssh://git@github.com/"]
	insteadOf = https://github.com/
  • Make sure your ssh key is properly configured in your github account, and it matches your user name
  • First test that it works as is, and observe that the remote is using SSH rather than https despite cloning http:
❯ git clone https://github.com/Rahix/avr-hal-template
Cloning into 'avr-hal-template'...
...
❯ cd avr-hal-template/
❯ git remote -v
origin	ssh://git@github.com/Rahix/avr-hal-template (fetch)          <--------------  THESE TWO MUST BE ssh://git@...
origin	ssh://git@github.com/Rahix/avr-hal-template (push)
❯ cd ..
❯ rm -rf avr-hal-template/
  • Run cargo generate --git https://github.com/rahix/avr-hal-template
❯ cargo generate --git https://github.com/rahix/avr-hal-template
Error: Please check if the Git user / repository exists.

Caused by:
    invalid or unknown remote ssh hostkey; class=Ssh (23); code=Certificate (-17)

Expected behavior
generation should start

Desktop (please complete the following information):

  • OS: Linux Mint
  • Version: 21.1
  • Build tools: a lot of them
  • Shell: bash
  • rustc --version: rustc 1.67.1 (d5a82bbd2 2023-02-07)
  • cargo generate --version: cargo generate-generate 0.17.6
@Yiwen-Gao
Copy link

I have the same Git setting to use SSH instead of HTTPS and ran into the same issue with:

cargo generate --git https://github.com/CosmWasm/cw-template.git --name cw --verbose

but my error message was:

Error: Please check if the Git user / repository exists.

Caused by:
    all authentication attempts failed

As a workaround, I commented out the insteadOf directive in my ~/.gitconfig, and cargo generate was able to authenticate and download everything correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants