gitblit-org / gitblit

pure java git solution
http://gitblit.com
Apache License 2.0
2.27k stars 671 forks source link

SSH : no matching host key type found. Their offer: ssh-rsa,ssh-dss #1384

Closed cshsoft closed 1 year ago

cshsoft commented 2 years ago

Use ssh-keygen -t RSA to generate a key pair and add the public key to the account. No matching host key type found. Their offer: ssh-rsa, ssh-dSS

flaix commented 2 years ago

You are probably using the latest version of OpenSSH, e.g. 8.8. OpenSSH has removed ssh-rsa from its defaults.

As a workaround you can enable it in your SSH client. For example on the command line, add -oHostKeyAlgorithms=+ssh-rsa to the SSH command: ssh -oHostKeyAlgorithms=+ssh-rsa user@192.168.8.109.

This is not practical for Git usage, so you can change it in your config. Add a section for your Git server to your ~/.ssh/config file like so:

Host gitblit.example.com
    HostkeyAlgorithms +ssh-rsa
    PubkeyAcceptedAlgorithms +ssh-rsa

See also Atlassian's article for a longer explanation. This workaround is necessary until Gitblit updates the server side host key generation.

cshsoft commented 2 years ago

I've tried that, but I still failed

flaix commented 2 years ago

Which SSH are you using and on what OS version?

cshsoft commented 2 years ago

libssh2-1.10.0

cshsoft commented 2 years ago

The operating system is Window 10

flaix commented 2 years ago

Now I am confused. That library explicitly lists only ssh-rsa and ssh-dss as the supported hostkey types. Also there is nothing to the contrary in the changelog. Is this a private project or some public git client I could use for testing?

cshsoft commented 2 years ago

Private project, server for Gitblit, running fine on my desktop but reporting an error on my laptop,and found new error:

Failed to retrieve list of ssh authentication methods: Failed getting response

flaix commented 2 years ago

In that case I am not sure how to best help you now. At some point Gitblit will have to update the Host key types, for OpenSSH 8.8. But your case seems different, since your library states that it still supports ssh-rsa.

As you use the library in your code you ought to be able to change the configuration for your program and to debug the communication.

andrm commented 2 years ago

try this in .ssh/config: Host mygitblit.server.com PubKeyAcceptedKeyTypes +ssh-rsa

Huihh commented 2 years ago

You can adding the lines below into the Host xxx.xxx.xxx.xxx(server ip) section of your SSH configuration:

Windows systems, this file is located at %USERPROFILE%.ssh\config or $(git_install folder)\etc\ssh\ssh_config.

Host xxx.xxx.xxx.xxx (gitblit server ip) HostkeyAlgorithms +ssh-rsa PubkeyAcceptedAlgorithms +ssh-rsa

good luck

shreeramjoshi2000 commented 2 years ago

I used @flaix suggestion "ssh -oHostKeyAlgorithms=+ssh-rsa user@192.168.8.109." and it worked fine. But found that I had to always had to specify the HostKeyAlgorithms when ssh to the host. Will try @andrm method and will update this comment

flaix commented 1 year ago

While the original seems like a error on the client side, this was still an issue for people using OpenSSH 8.8. This has been fixed by supporting additional host key types in PR #1429

jcasale commented 1 year ago

@flaix Will this show up in the nightly? I looked at docker hub and it seems the nightly has not been updated for 7 months?

flaix commented 1 year ago

Yes, it should. The last nightly run failed to deploy to Docker Hub. I hope this one works, otherwise I have to make it work again.

flaix commented 1 year ago

@jcasale The last nightly successfully deployed to Docker Hub.