git-bug icon indicating copy to clipboard operation
git-bug copied to clipboard

Error: ssh: handshake failed: knownhosts: key mismatch

Open jarbus opened this issue 2 years ago • 13 comments

I can pull/push my repo from github fine, but I can't push bugs. When I do, I get the following error:

➜ git bug push
Error: ssh: handshake failed: knownhosts: key mismatch

I'm using v0.8.0 on arch linux. I've got all my ssh keys in my knownhosts file.

jarbus avatar Nov 24 '22 18:11 jarbus

Apologies if this is just a bug with my ssh config, but I'm imagining there is an assumption of how ssh should be configured for gitbug that I'm missing.

jarbus avatar Nov 24 '22 18:11 jarbus

It could be a go-git issue. Git-bug use go-git for every git manipulation, including push/pull. From what I've seen, it can get confused sometimes by some configurations.

MichaelMure avatar Nov 24 '22 18:11 MichaelMure

I'm using v0.8.0 on arch linux

I'm also on Arch Linux and experienced the same issue. I solved it like this:

$ for keytype in rsa ecdsa ed25519; do
    ssh-keyscan -t "$keytype" github.com >> ~/.ssh/known_hosts
  done
$ 

kseistrup avatar Nov 25 '22 10:11 kseistrup

Mentioned in https://github.com/go-git/go-git/issues/619, go-git may have a fix for this but it's not in a tagged version yet.

MichaelMure avatar Nov 25 '22 10:11 MichaelMure

I'm also on Arch Linux and experienced the same issue. I solved it like this:

$ for keytype in rsa ecdsa ed25519; do
    ssh-keyscan -t "$keytype" github.com >> ~/.ssh/known_hosts
  done
$ 

Just made an ecdsa key to try this, I get the following error:

Error: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain

But the error goes back to the initial key mismatch error if I remove the ecdsa entry

jarbus avatar Nov 26 '22 03:11 jarbus

Hm… :thinking:

I didn't create an ecdsa key, I just fetched the three keytypes from remote with the ssh-keyscan thing, but there must be some other differences in our setup since it doesn't work at your end.

kseistrup avatar Nov 26 '22 09:11 kseistrup

I'm also on Arch Linux and experienced the same issue. I solved it like this:

$ for keytype in rsa ecdsa ed25519; do
    ssh-keyscan -t "$keytype" github.com >> ~/.ssh/known_hosts
  done
$ 

Thanks, this solved the issue for me!

maciej-trebacz avatar Nov 28 '22 11:11 maciej-trebacz

Still not working for me, even building from source with the latest version of go-git :(

jarbus avatar Nov 30 '22 01:11 jarbus

Update: Got it to work by ssh-add'ing my rsa key

jarbus avatar Nov 30 '22 01:11 jarbus

Update: Got it to work by ssh-add'ing my rsa key

Doesn't work for me both ssh-add and the for loop above :( I'm using Gitlab.

ssh-keygen -l -v -f ~/.ssh/id_rsa.pub
3072 SHA256:AxuOIT7oMjUmrtt4x90l2K6qJHRSf2FyjjL8rvvfRPA user@host (RSA)
+---[RSA 3072]----+
|                 |
|                 |
|  ....o=         |
| oo..+*++        |
|oo*=.oo=SE       |
|++oo+ o +..      |
|+o.. o o +       |
|o*. + . =        |
|+oo==+oo .       |
+----[SHA256]-----+

More:

cat ~/.ssh/config
Host *
  IdentityFile ~/.ssh/id_rsa
  KexAlgorithms +diffie-hellman-group14-sha1

cat ~/.ssh/known_hosts | grep gitlab.com
gitlab.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCsj2.....xxxxxxASUEMaieWVNTRCtJ4S8H+9

git bug bridge push works, btw.

halloumee avatar Dec 02 '22 17:12 halloumee

I'm getting a kind of similar but different error:

prologic@Jamess-iMac
Sat Dec 24 16:19:04
~/Projects/legit
 (main) 0
$ git bug push
Error: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain

Apparently it doesn't know how to auth? 🤔 Normally I use a running ssh-agent

prologic avatar Dec 24 '22 06:12 prologic

I hit this issue with 0.8.0 (on OSX from brew) and solved it by removing the brew version and compiling the latest master from source. After that git bug push worked.

ttiurani avatar Jan 20 '23 09:01 ttiurani

This bot triages untriaged issues and PRs according to the following rules:

  • After 90 days of inactivity, the lifecycle/stale label is applied
  • After 30 days of inactivity since lifecycle/stale was applied, the issue is closed

To remove the stale status, you can:

  • Remove the lifecycle/stale label
  • Comment on this issue

github-actions[bot] avatar Jul 23 '24 03:07 github-actions[bot]