简体   繁体   中英

"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. 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.

When I type in this command: "ssh -T git@github.com", I just get:

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. 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

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 . 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. I did not do any alteration on my git repositories at all. Restarting my connection fixed it.

Do git-init. It will reinitialize the connection

The same thing happened to me with Bitbucket today. I first tried git init as another reply suggested. 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:

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. Once I changed the port in /etc/ssh/ssh_config back to 22, I was able to connect to 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 was doing major maintenance on their site and said would be down for two hours.

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. The git bash error message is quite cryptic. 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.
  • After you will get the git folder in your cloned project.
  • copy that git folder and replace it with your SSL error showing project.
  • then as usual git add. 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. 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. 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. 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 ):

$ 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.

On Windows or WSL, open a admin powershell and execute ipconfig /flushdns . Then reboot WSL with wsl.exe -t Ubuntu and maybe the whole PC.

On Ubuntu + VSCode Terminal and using Bitbucket:

Restarting didn't work.

Reinitialize the repo worked:

$ git init

My case is same with @osama-heba in his answer .

The solution is to change port. If it is 22, try to change to 443 and vice-versa.

  1. In ubuntu, change the port on:

     sudo nano ~/.ssh/config
  2. Try remove origin and add it again (here, I use GitHub for example),

     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:

     ssh -T git@github.com

None of these worked for me: restart wifi card, git init. I did not try rebooting.

I only see this problem when using IDE like PyCharm, and only since a couple of months.

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.

A web search indicates github does not throttle git fetch, but maybe it's a recent change that hasn't been announced yet?

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

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

I was facing the problem because I got connected to one of the 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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