简体   繁体   English

尝试连接到 git 上的远程存储库时出现“ssh_exchange_identification: read: Connection reset by peer”错误

[英]"ssh_exchange_identification: read: Connection reset by peer" error when trying to connect to remote repository on git

I'm very new to github, I started using it about two weeks ago.我是 github 的新手,我大约两周前开始使用它。 Everything worked perfectly, I was able to push and pull from my remote repository.一切都很完美,我能够从我的远程存储库中推送和拉取。 Today, however, when I tried to pull from it I got this error message:然而,今天,当我试图从中提取时,我收到了这条错误消息:

ssh_exchange_identification: read: Connection reset by peer
fatal: Could not read from remote repository.

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

When I try to do anything that connects to my remote github repository (push, pull, fetch, etc), in fact, it gives me back the same error.当我尝试执行任何连接到我的远程 github 存储库(推送、拉取、获取等)的操作时,实际上,它会返回相同的错误。

When I type in this command: "ssh -T git@github.com", I just get:当我输入这个命令时:“ssh -T git@github.com”,我得到:

ssh_exchange_identification: read: Connection reset by peer

I didn't modify any settings in my repository or in my SSH keys or anything so I have no idea why it stopped working all of a sudden.我没有修改我的存储库或我的 SSH 密钥或任何东西中的任何设置,所以我不知道为什么它突然停止工作。 What could be the problem?可能是什么问题呢?

I had a similar issue recently, I'm not sure whether its exactly the same as I got the connected user by following command.我最近遇到了类似的问题,我不确定它是否与我通过以下命令获得连接的用户完全相同。

ssh -T git@gitlab.com ssh -T git@gitlab.com

But when I try to push the code to remote repository I got same error.但是当我尝试将代码推送到远程存储库时,我得到了同样的错误。

kex_exchange_identification: read: Connection reset by peer
fatal: Could not read from remote repository.

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

After trying few solutions from the internet without success, I just tried git init and it worked for me .在尝试了互联网上的几个解决方案但没有成功后,我刚刚尝试git init它对我有用。 I hope this works only if the connection user has bound correctly.我希望这仅在连接用户已正确绑定时才有效。

Try it out Good Luck..:)试试看 祝你好运.. :)

I also had this problem and I was able to fix it by restarting my internet connection.我也遇到了这个问题,我可以通过重新启动我的互联网连接来解决它。

I was so confused when git bash suddenly gave me that message.当 git bash 突然给我这个消息时,我很困惑。 I did not do any alteration on my git repositories at all.我根本没有对我的 git 存储库进行任何更改。 Restarting my connection fixed it.重新启动我的连接修复了它。

Do git-init.做 git-init。 It will reinitialize the connection它将重新初始化连接

The same thing happened to me with Bitbucket today.今天在 Bitbucket 上也发生了同样的事情。 I first tried git init as another reply suggested.我首先尝试git init作为另一个答复建议。 No luck.没运气。 Then simply enough, I just rebooted my PC and it all started working again.然后很简单,我刚刚重新启动了我的电脑,一切又开始工作了。

I had the same thing and this worked for me:我有同样的事情,这对我有用:

git config http.sslVerify "false"

And then:接着:

git remote rename origin old-origin

and then instead of using ssh (git@YOUR_GIT_REPO.git) used the https url and set that as origin:然后代替使用 ssh (git@YOUR_GIT_REPO.git) 使用https url 并将其设置为原点:

git remote add origin https://YOUR_GIT_REPO.git

In my case was because the ssh port at /etc/ssh/ssh_config file was changed.在我的情况下,是因为 /etc/ssh/ssh_config 文件中的 ssh 端口已更改。 Once I changed the port in /etc/ssh/ssh_config back to 22, I was able to connect to Gitlab.一旦我将 /etc/ssh/ssh_config 中的端口改回 22,我就能够连接到 Gitlab。

I got this error today and wondered what had gone wrong.我今天遇到了这个错误,想知道出了什么问题。 Rebooted.重新启动。 Still bad.还是很糟糕。 Then I went to gitlab website and got a 503 Error indicating server unavailable.然后我去了 gitlab 网站,得到一个 503 错误,表明服务器不可用。 gitlab was doing major maintenance on their site and said would be down for two hours. gitlab 正在他们的网站上进行重大维护,并表示将关闭两个小时。

I'm just posting this in case others have this problem.我只是发布这个以防其他人有这个问题。 In this case it was not a local problem but the remote git server.在这种情况下,这不是本地问题,而是远程 git 服务器。 The git bash error message is quite cryptic. git bash 错误消息非常神秘。 It said:它说:

kex_exchange_identification: read: Connection reset by peer
Connection reset by 2606:4700:90:0:f22e:fbec:5bed:a9b9 port 22
fatal: Could not read from remote repository.

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

I have resolved this error after a lot of struggle but I think its a dumb idea but it will work.经过一番努力,我已经解决了这个错误,但我认为这是一个愚蠢的想法,但它会起作用。

  • Go to your git projects and clone it by HTTP link in your system. Go 到您的 git 项目并通过系统中的 HTTP 链接克隆它。
  • After you will get the git folder in your cloned project.之后,您将在克隆项目中获得 git 文件夹。
  • copy that git folder and replace it with your SSL error showing project.复制 git 文件夹并将其替换为 SSL 错误显示项目。
  • then as usual git add.然后像往常一样添加 git。 and so on.it will push normally.以此类推。它会正常推送。

Enjoy享受

same problem is here I also got same error.同样的问题在这里我也有同样的错误。 But after deleting.git file it works fine but somehow repeated again and again.. kex_exchange_identification: read: Connection reset by peer Connection reset by 13.234.210.38 port 22 fatal: Could not read from remote repository.但在删除.git 文件后,它工作正常,但不知何故一次又一次地重复.. kex_exchange_identification:读取:对等连接重置连接由 13.234.210.38 端口 22 重置致命:无法从远程存储库读取。 Please make sure you have the correct access rights.请确保您拥有正确的访问权限。 and the repository exists.并且存储库存在。

I had this issue because I had incorrectly added a new remote repo (called origin ) to my local git repo copy.我遇到了这个问题,因为我错误地将一个新的远程仓库(称为origin )添加到我的本地 git 仓库副本中。 You can view all your remotes like so:您可以像这样查看所有遥控器:

$ git remote -v
origin  git@my-host.com:1234/my-path/my-project.git (fetch)
origin  git@my-host.com:1234/my-path/my-project.git (push)

Notice how the protocol ( ssh:// ) is missing.请注意协议 ( ssh:// ) 是如何丢失的。 This was causing the error for me.这对我来说是错误的。 So just delete the old remote repos:所以只需删除旧的远程仓库:

$ git remote rm origin
$ git remote -v
# empty

Then add the correct remote repo (called origin ):然后添加正确的远程仓库(称为origin ):

$ git remote add origin ssh://git@my-host.com:1234/my-path/my-project.git
$ git remote -v
origin  ssh://git@my-host.com:1234/my-path/my-project.git (fetch)
origin  ssh://git@my-host.com:1234/my-path/my-project.git (push)

I had to flush dns to resove this problem.我不得不刷新 dns 来解决这个问题。

On Windows or WSL, open a admin powershell and execute ipconfig /flushdns .在 Windows 或 WSL 上,打开管理员 powershell 并执行ipconfig /flushdns Then reboot WSL with wsl.exe -t Ubuntu and maybe the whole PC.然后使用wsl.exe -t Ubuntu重新启动 WSL,也许是整个 PC。

On Ubuntu + VSCode Terminal and using Bitbucket:在 Ubuntu + VSCode 终端上并使用 Bitbucket:

Restarting didn't work.重新启动没有用。

Reinitialize the repo worked:重新初始化回购工作:

$ git init

My case is same with @osama-heba in his answer .我的情况与他的回答中的@osama-heba 相同。

The solution is to change port.解决方案是更改端口。 If it is 22, try to change to 443 and vice-versa.如果是 22,尝试更改为 443,反之亦然。

  1. In ubuntu, change the port on:在 ubuntu 中,更改端口:

     sudo nano ~/.ssh/config
  2. Try remove origin and add it again (here, I use GitHub for example),尝试删除原点并重新添加它(这里,我使用 GitHub 例如),

     git remote rm origin git remote add origin git@github.com:USERNAME/REPONAME.git
  3. To test and initilaize connection, you can push or pull from the remote.要测试和初始化连接,您可以从远程推送或拉取。 Alternatively in GitHub, use:或者在 GitHub 中,使用:

     ssh -T git@github.com

None of these worked for me: restart wifi card, git init.这些都不适合我:重启 wifi 卡,git init。 I did not try rebooting.我没有尝试重新启动。

I only see this problem when using IDE like PyCharm, and only since a couple of months.我只在像 PyCharm 这样使用 IDE 时才看到这个问题,而且只有几个月。

In my case I have about 20 git repos hosted in github. If I only update a small number of git repos, the problem does not occur.在我的例子中,我有大约 20 个 git 存储库托管在 github 中。如果我只更新少量 git 存储库,则不会出现问题。

A web search indicates github does not throttle git fetch, but maybe it's a recent change that hasn't been announced yet? web 搜索表明 github不会限制 git 获取,但也许这是尚未公布的最新更改?

This same problem also happened to me on my bitbucket repository, all I did was delete this repository and create another one with another name, and in locla I only modified the url of remote同样的问题也发生在我的 bitbucket 存储库上,我所做的只是删除这个存储库并用另一个名称创建另一个,在 locla 我只修改了远程的 url

git remote set-url origin git@bitbucket.org:USERNAME/REPOSITORY.git

To find out more about changing the URL of your repository, click on the link here: changing-a-remotes-url要了解有关更改存储库的 URL 的更多信息,请单击此处的链接:changeing -a-remotes-url

I was facing the problem because I got connected to one of the VPN我遇到了这个问题,因为我连接到了其中一个 VPN

The access point you are using might be blocking certain type of communication.您使用的接入点可能会阻止某些类型的通信。 I just faced the problem while using my university's wifi network and when I changed the connection to my mobile's service it worked just fine我只是在使用我大学的 wifi 网络时遇到了这个问题,当我将连接更改为我的手机服务时,它工作得很好

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM