17

When I try to connect using git, then I see this error

$ git clone git@github.com:MyCompany/eagle.git --verbose                                         
Cloning into 'eagle'...                                                                        
FATAL ERROR: Couldn't agree a key exchange algorithm (available: curve25519-sha256@libssh.org,ecdh-sh
a2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521)                                                   
fatal: Could not read from remote repository.                                                        

Please make sure you have the correct access rights                                                  
and the repository exists.

I setuped all keys, etc and connection works fine, because when I do ssh -v git@github.com connection is successful.

What could I do to understand what went wrong and what should be corrected ?

Thanks,

torek
  • 448,244
  • 59
  • 642
  • 775
Bill Lumbert
  • 4,633
  • 3
  • 20
  • 30

5 Answers5

14

For me, this was happening because:

  1. I had Git configured to use PuTTY (i.e. GIT_SSH=C:\Program Files\PuTTY\plink.exe)
  2. I was running an old version of PuTTY (e.g. 0.63)
  3. GitHub has recently removed weak cryptography standards.

I uninstalled PuTTY 0.63 and downloaded and installed the latest version of PuTTY (at this time, 0.70), and that solved the problem for me.

mfisherca
  • 2,399
  • 22
  • 22
  • I upgraded my PuTTY as well but after switching over to a different key type (trying to figure out one that sort of matched one in the list I was getting in the error). I ended up upgrading PuTTY only because Pagaent couldn't load the keys I had just created! – dash-tom-bang Sep 02 '18 at 19:54
7

If ssh -T git@github.com gives you the:

Hi <name>! You've successfully authenticated, but GitHub
does not provide shell access.

message, that means your ssh setup is working. If you get a:

FATAL ERROR: Couldn't agree a key exchange algorithm ...

that means your ssh setup isn't working. Clearly there's a contradiction here, and the most likely culprit is that you have two different ssh commands installed: one that you are using, which works, and another that Git is using, which doesn't.

This answer to Git with SSH on Windows has a lot of upvotes. I avoid Windows, so I have no idea whether this will help. (I don't even know if you're on Windows since you have not mentioned it.)

Note that Git version 2.3.0 added GIT_SSH_COMMAND, and Git version 2.10.0 added core.sshCommand to set a value for GIT_SSH_COMMAND. Since then, Git version 2.13.0 learned some new tricks for dealing with issues tied to variations of ssh that demand different option letters. In all cases it's important to figure out which ssh Git is running, and make sure it runs one that actually works. See the top level Git documentation for a description of all the option variables and what they do. The link here goes to a web page that may not match your own Git version, so consider running git --help git to read that version, if your Git is very old.

torek
  • 448,244
  • 59
  • 642
  • 775
4

the problem was in GIT_SSH. this variable has been set by putty before. I deleted this env variable and problem has been solved

Ambroise Rabier
  • 3,636
  • 3
  • 27
  • 38
Bill Lumbert
  • 4,633
  • 3
  • 20
  • 30
1

This may have to do with GitHub removing weak crypto. This happend about Feb 22, 2018.

Paul Vincent Craven
  • 2,027
  • 3
  • 19
  • 24
0

I've been using SourceTree, then putty, then open-ssh. Actually did a mess and was using the putty installed with SourceTree when checking GIT_SSH env variable value. Deleting this env variable was needed to use open-ssh. (not using putty so)

For neophyte I am using this snippet to "login" to github with open-ssh: eval $(ssh-agent -s) && ssh-add ~/.ssh/mySHHKey

EDIT: nevermind I successfully connected yesterday but now it stopped working... Using pageant with putty in meantime.

Ambroise Rabier
  • 3,636
  • 3
  • 27
  • 38