Reputation: 341
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 [email protected]", 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?
Upvotes: 31
Views: 72717
Reputation: 441
In this particular instance was trying to fetch a remote branch from a branch that was only available locally. Switched to one that already exists remotely and was able to pull the necessary changes.
Switched to branch that exists remotely.
Upvotes: 0
Reputation: 1
I also got this same error.while pulling from gitlab.then i again pull. this time i didn't get.It sucessfully pull.
Upvotes: -1
Reputation: 190
These are the steps worked for me in a setup where my company requires sso authorization for the ssh git access to work.
Generate ssh key:
ssh-keygen -t ed25519 -C "[email protected]"
Go to https://github.com/settings/keys and add the content of ~/.ssh/id_ed25519.pub file into a new key using "New SSH Key".
Authorize the new key to use SSO using "Configure SSO -> authorize" option.
Add the following content to ~./ssh/config
Host github.com
HostName ssh.github.com
Port 443
Test the access status:
ssh -T [email protected]
Upvotes: 1
Reputation: 129
If you use clash, try adding port 22 mode in config file
Reference: https://github.com/vernesong/Open Clash/issues/1960#issuecomment - 1052075603
https://docs.github.com/zh/authentication/troubleshooting-ssh/using-ssh-over-the-https-port
Upvotes: 0
Reputation: 141
So, I lost quite a bit of time on this, and the error was not difficult to fix so I figured I would just share it.
My goal was to clone a repo from gitlab to a remote server, and it was the first time that this remote server was acting as a client in a ssh communication.
Which means I never realized that I messed up when setting up the server, and that I did set the default SSH port to a custom port for BOTH the ssh client and ssh server.
So the actual fix was to edit the file /etc/ssh/ssh_config
and commenting the line Port XXXXX
.
If you want to keep this parameter, you can contact the ssh server on the right port (for gitlab.com it is the port 22, the default one):
ssh -Tvvv [email protected] -p 22
For cloning:
git clone ssh://[email protected]:22/some-path/some-name.git
I hope this will help someone :)
Upvotes: 1
Reputation: 487
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.
Upvotes: 0
Reputation: 59
I have also faced this problem and I was unable to push anything to Github or even ssh into my Linux servers. After days of troubleshooting and researching, I realised it was to do with the internet connection I was connected to. When I connected to a different network (From a different provider), I was able to proceed normally with pushing to GitHub and SSH-ing to the Linux servers. Try to change your internet connection i.e to a different router/provider e.t.c and see if it also works for you.
Upvotes: 1
Reputation: 29573
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?
Upvotes: 0
Reputation: 2167
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.
In ubuntu, change the port on:
sudo nano ~/.ssh/config
Try remove origin and add it again (here, I use GitHub for example),
git remote rm origin
git remote add origin [email protected]:USERNAME/REPONAME.git
To test and initilaize connection, you can push or pull from the remote. Alternatively in GitHub, use:
ssh -T [email protected]
Upvotes: 1
Reputation: 1455
On Ubuntu + VSCode Terminal and using Bitbucket:
Restarting didn't work.
Reinitialize the repo worked:
$ git init
Upvotes: -1
Reputation: 420
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.
Upvotes: 3
Reputation: 49
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.
Upvotes: 0
Reputation: 4435
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 [email protected]:1234/my-path/my-project.git (fetch)
origin [email protected]: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://[email protected]:1234/my-path/my-project.git
$ git remote -v
origin ssh://[email protected]:1234/my-path/my-project.git (fetch)
origin ssh://[email protected]:1234/my-path/my-project.git (push)
Upvotes: 0
Reputation: 29
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
Upvotes: 1
Reputation: 878
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.
Upvotes: 1
Reputation: 415
I was facing the problem because I got connected to one of the VPN
Upvotes: 0
Reputation: 1107
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 [email protected]
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.. :)
Upvotes: 25
Reputation: 191
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.
Upvotes: 19
Reputation: 13
I have resolved this error after a lot of struggle but I think its a dumb idea but it will work.
Enjoy!
Upvotes: 0
Reputation: 69
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
Upvotes: 3
Reputation: 9
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 [email protected]:USERNAME/REPOSITORY.git
To find out more about changing the URL of your repository, click on the link here : changing-a-remotes-url
Upvotes: -1
Reputation: 570
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.
Upvotes: 4