git找不到正确的ssh

Bil*_*ert 10 git ssh github ssh-keys

当我尝试使用git连接时,我看到了这个错误

$ 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.
Run Code Online (Sandbox Code Playgroud)

我设置了所有密钥等,连接工作正常,因为当我 ssh -v git@github.com连接成功时.

我该怎么做才能理解出了什么问题以及应该纠正什么?

谢谢,

mfi*_*rca 10

对我而言,这种情况正在发生,因为:

  1. 我让Git配置为使用PuTTY(即GIT_SSH=C:\Program Files\PuTTY\plink.exe)
  2. 我正在运行旧版PuTTY(例如0.63)
  3. GitHub最近删除了弱加密标准.

我卸载了PuTTY 0.63并下载并安装了最新版本的PuTTY(此时为0.70),这解决了我的问题.


tor*_*rek 5

如果ssh -T git@github.com给你:

Hi <name>! You've successfully authenticated, but GitHub
does not provide shell access.
Run Code Online (Sandbox Code Playgroud)

消息,这意味着您的ssh设置正常.如果你得到一个:

FATAL ERROR: Couldn't agree a key exchange algorithm ...
Run Code Online (Sandbox Code Playgroud)

这意味着你的ssh设置无法正常工作.显然这里存在矛盾,最可能的罪魁祸首是你安装了两个不同的ssh命令:一个是你正在使用的,哪个是有效的,另一个是Git正在使用的,但是没有.

这个答案的Git在Windows SSH有很多upvotes的.我避免使用Windows,因此我不知道这是否会有所帮助.(我甚至不知道你是否在Windows上,因为你还没有提到它.)

请注意,添加GIT_SSH_COMMANDGit版本2.3.0,并添加core.sshCommand了Git版本2.10.0 来设置值GIT_SSH_COMMAND.从那以后,Git版本2.13.0学会了一些处理与需要不同选项字母的ssh变体相关的问题的新技巧. 在所有情况下,确定哪个ssh Git正在运行很重要,并确保它运行一个实际工作的.有关所有选项变量及其功能的说明,请参阅顶级Git文档.这里的链接转到一个可能与您自己的Git版本不匹配的网页,因此git --help git如果您的Git很老,请考虑运行以阅读该版本.