簡體   English   中英

克隆git存儲庫的問題

[英]Issue with cloning git repository

我正在嘗試克隆 git 存儲庫,但出現錯誤

Unable to negotiate with <server>: no matching key exchange method found.
Their offer: diffie-hellman-group1-sha1
fatal: Could not read from remote repository.

我編輯了~/.ssh/config並添加了

Host somehost.example.org
KexAlgorithms +diffie-hellman-group1-sha1"

但我仍然遇到同樣的錯誤。

其他解決方案是使用命令ssh -oKexAlgorithms=+diffie-hellman-group1-sha1 user@127.0.0.1 -p 2222但我的連接也被拒絕,端口號為 22。

我正在使用 Windows 機器。

touch ~/.ssh/config

為遇到相同問題的人附上我的 ssh 配置

## use kex algorithm ##
Host 10.172.4.66
    KexAlgorithms diffie-hellman-group1-sha1

## Avoid Write failed : boken pipe issue ##
ServerAliveInterval 120
TCPKeepAlive no

如果遇到另一個問題,請使用更大的 postBuffer

 fatal: The remote end hung up unexpectedly fatal: early EOF fatal: index-pack failed
$ git config --global http.postBuffer 10000000000000000000000000000000

$ git clone ssh://xxx xx
Cloning into 'xx'...
remote: Counting objects: 105491, done.
remote: Compressing objects: 100% (32876/32876), done.
Receiving objects: 100% (105491/105491), 1.74 GiB | 19.55 MiB/s, done.
remote: Total 105491 (delta 67211), reused 104583 (delta 66603)
Resolving deltas: 100% (67211/67211), done.
Checking connectivity... done.
Checking out files: 100% (16545/16545), done.

使用以下內容附加文件C:\\Program Files\\Git\\etc\\ssh\\ssh_config對我有用

KexAlgorithms +diffie-hellman-group1-sha1,diffie-hellman-group14-sha1

(干杯🍻)

我正在使用 Windows,因為我的情況 git clone 在 Jenkins 中失敗(在系統用戶下運行)。

添加

Host somehost.example.org
   KexAlgorithms +diffie-hellman-group1-sha1

進入~/.ssh/config將使克隆在當前用戶工作時運行。

對於其他用戶,OpenSSH 不會選擇配置。 我必須將上述配置添加到全局配置文件中: “C:\\Program Files\\Git\\etc\\ssh\\ssh_config”才能使其工作。

這發生在我更新了 git-for-windows 客戶端之后,新的 git 禁用了一些舊的密鑰交換方法。 另一種解決方法是安裝舊版本的 git。 例如: https : //github.com/git-for-windows/git/releases/tag/v2.20.1.windows.1

您的問題在此處詳細描述:

如果客戶端和服務器無法就一組相互的參數達成一致,則連接將失敗。
OpenSSH(7.0 及更高版本)將產生如下錯誤消息:
Unable to negotiate with 127.0.0.1: no matching key exchange method found. Their offer: diffie-hellman-group1-sha1


設置備用 ssh 密鑰

ssh-keygen -t rsa -C <your comment>

現在在您的服務器帳戶下添加公鑰並重試。

Host     xxxx.yyyy.com 
KexAlgorithms +diffie-hellman-group1-sha1
Port     portNumber
User     userName-yourDomain-com

在 .config 文件中包含以上行,並在 id_rsa.pub 和其他文件所在的 .ssh 目錄中添加 .config 文件。

當客戶端和服務器無法就要使用的密鑰交換算法達成一致時,就會發生此錯誤。 您可以在錯誤日志中看到服務器提供使用的密鑰交換算法。 如果您的客戶端無法使用服務器提供的方法,則會引發錯誤。 要解決此問題,可以在客戶端或服務器端進行更改。 如果您可以更改服務器的配置,那將是更好的選擇,因為您不必對所有客戶端進行更改。 要解決服務器端的問題,您需要升級/配置服務器以不使用不推薦使用的算法。

如果無法在服務器端進行更改,則可以簡單地強制客戶端重新啟用服務器准備使用的密鑰交換算法。 您可以通過更新 linux 上的~/.ssh/config文件或 windows 上的C:\\Program Files\\Git\\etc\\ssh\\ssh_config文件並添加以下行來實現此永久性:

Host example.org # you can use the * wildcard character. e.g. *.example.org or simplly * for all hosts
User yourUserName # optional
KexAlgorithms +diffie-hellman-group1-sha1 # you can also specify multiple algorithms by separating them with comma e.g. diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1

如果您使用的是 Windows 並且在 tortoise Git 或 Sourcetree 中發生此錯誤,請嘗試使用 puttYGen 生成您的密鑰。 或者使用 puttYGen 從您現有的私鑰創建一個新密鑰(使用加載選項),然后將該私鑰以擴展名 ppk 保存在任何文件夾中。 之后,在選美中添加此密鑰(帶有擴展名ppk)(谷歌知道圖標如何,它必須出現在小時旁邊的右下角)右鍵單擊並添加密鑰。 盡量確保你設置你的烏龜或你的源樹來使用這個 ppk 密鑰。 Tortoise:設置 - 網絡 - ssh 客戶端(必須是 TortoiseGitPLink.exe,如果不是在 git Tortoise git_home\\bin 文件夾中) 源樹:工具 - 選項 - Ssh 客戶端 Putty/PLink

如果您使用的是 VS 2019 中的 Git Changes 並遇到相同問題,您可以從客戶端解決該問題以重新啟用密鑰交換算法。 您可以通過更新Windows 上C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\Common7\\IDE\\CommonExtensions\\Microsoft\\TeamFoundation\\Team Explorer\\Git\\etc\\ssh文件並添加以下內容來永久執行此操作線:

KexAlgorithms +diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM