21

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?

phd
  • 69,888
  • 11
  • 97
  • 133
forblaze13
  • 241
  • 1
  • 2
  • 3
  • 6
    Execute `ssh -vvv -T git@github.com`, it will show debug information about the connection. – Gonzalo Matheu Feb 09 '19 at 23:35
  • @GonzaloMatheu, I executed it and it returned this (I'll split it into two comments because of the character limit): OpenSSH_7.7p1, OpenSSL 1.0.2p 14 Aug 2018 debug1: Reading configuration data /c/Users/b/.ssh/config debug1: /c/Users/b/.ssh/config line 2: Applying options for github.com debug1: Reading configuration data /etc/ssh/ssh_config debug2: resolving "github.com" port 22 debug2: ssh_connect_direct: needpriv 0 debug1: Connecting to github.com [192.30.253.113] port 22. debug1: Connection established. debug1: identity file /c/Users/b/.ssh/id_rsa type 0 – forblaze13 Feb 09 '19 at 23:43
  • debug1: key_load_public: No such file or directory debug1: identity file /c/Users/b/.ssh/id_rsa-cert type -1 debug1: Local version string SSH-2.0-OpenSSH_7.7 ssh_exchange_identification: read: Connection reset by peer – forblaze13 Feb 09 '19 at 23:44
  • This question might help -> https://unix.stackexchange.com/questions/321968/trying-to-ssh-into-server-and-getting-key-load-public-no-such-file-or-directory – Gonzalo Matheu Feb 09 '19 at 23:56
  • I didn't understand much from it, could you please explain the solution provided there? It seems it's for a different context than github. – forblaze13 Feb 10 '19 at 02:35
  • I have already answered here: https://stackoverflow.com/a/64100419/3437897 – Ghulam Akbar Sep 28 '20 at 10:40

12 Answers12

20

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

Kandy
  • 1,001
  • 12
  • 28
12

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.

dhaynamicoGrant
  • 121
  • 1
  • 5
7

Do git-init. It will reinitialize the connection

Nitishgarg
  • 81
  • 1
  • 1
3

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.

Onur D.
  • 450
  • 3
  • 11
  • I have been trying to push to git from terminal. Simply, closing and than reopening the terminal has solved the case. – ni8mr Mar 20 '22 at 08:16
2

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
rolhai123
  • 49
  • 2
  • 5
1

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.

Cristian Zumelzu
  • 716
  • 8
  • 14
0

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!

0

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.

satyendra singh
  • 429
  • 1
  • 3
  • 5
0

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)
mulllhausen
  • 4,069
  • 7
  • 45
  • 69
-1

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

-1

I was facing the problem because I got connected to one of the VPN

user2694064
  • 197
  • 1
  • 4
  • In my case for bitbucket, i have to turn on my VPN on my Mac OS, so this can be also bug from my VPN application. – Rhony Jun 03 '22 at 03:19
-1

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

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 29 '22 at 11:16
  • This does not really answer the question. If you have a different question, you can ask it by clicking [Ask Question](https://stackoverflow.com/questions/ask). To get notified when this question gets new answers, you can [follow this question](https://meta.stackexchange.com/q/345661). Once you have enough [reputation](https://stackoverflow.com/help/whats-reputation), you can also [add a bounty](https://stackoverflow.com/help/privileges/set-bounties) to draw more attention to this question. - [From Review](/review/late-answers/31400372) – tjheslin1 Mar 31 '22 at 06:23
  • No I do not have a question. I was suggesting that the person with problem should make sure that the internet network s\he is using is not blocking certain traffic protocols – Osama Heba Apr 01 '22 at 07:09