0

Can anyone explain why we get this error:

fatal: Could not read from remote repository.

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

I got a few solutions from this post. But I didn't get any explanation to why or what creates the problem.

I changed my config file to this:

#account- github
Host github.com
 HostName ssh.github.com
 Port 443
 IdentityFile ~/.ssh/github_id_ed25519

My hostname was previously github.com so I made that ssh.github.com and included a port number. But I still want an explanation to why this happens.

Is this a OS related problem? Or just a network issue?

I mean changing port and using some other port cannot be the answer right, there should be an explanation

2 Answers2

0

I think you might not have an ssh key for your computer/instance added to your account, so you can't access the repository.

See: https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account

Andrew Wei
  • 870
  • 1
  • 7
  • 12
  • I have 3 ssh keys added to my config file. Github, GitlabCodemaster and bitbucket. All of them works perfectly fine without the occasional errors. And according to the post I have already mentioned in my question, I have seen people suggest restarting the PC and changing the port number etc. So I thought there must be a permanent solution or explanation to the problem –  Aug 21 '21 at 09:34
  • From the solution you posted, did you see the quote: "Sometimes, firewalls refuse to allow SSH connections entirely. If using HTTPS cloning with credential caching is not an option, you can attempt to clone using an SSH connection made over the HTTPS port. Most firewall rules should allow this, but proxy servers may interfere" – Andrew Wei Aug 21 '21 at 09:47
  • Port 443 is https, which allows for secure connections. So I think it's a security issue? – Andrew Wei Aug 21 '21 at 09:50
0

... changing port and using some other port cannot be the answer right, there should be an explanation

It could be the answer. This depends on your network administrator.

Some people appear to have concluded that access to the Internet is dangerous (which is true) and are therefore trying to choke it off. This is, to be sure, a solution, just as noting that the Sun is dangerous (ever get a nasty sunburn?) and therefore deciding that the solution is to "Stamp Out The Sun".1

If your network admin decided that the solution to Internet Danger was to prevent you, personally, from ever accessing any server's port 22, then any access to github.com's port 22 is blocked to you. Everyone else—well, almost everyone else—can use it, but you can't.

Instead of fixing this problem at the source—i.e., your network administrator—GitHub themselves have specifically decided to allow users to work around their network administrators by offering ssh access via port 443, which is nominally the https:// protocol port. This does actually work for some people. (This "deny access to port 22" thing is more common than one might first believe, if one understands Internet protocols. Those who don't understand Internet protocols think that denying access to specific ports, or all but some specific ports, will be successful. It won't, as this particular GitHub trick shows.)

Unfortunately, some network administrators not only block some ports, but also filter traffic that goes through the unblocked ports. This filtering is not supposed to corrupt the data that goes through that port, but does in fact corrupt it sometimes. Technologies exist to work around this as well,2 but must be implemented at both ends of the connection—both your computer, and GitHub's computers must do it.

The usual workaround for this is to use a VPN.3 Consider installing one.


1This was a fake movement my brother made up in the 1970s, if I remember right.

2Error detection and correction.

3VPNs, correctly configured, will do the EDAC mentioned in footnote 2, and will also tunnel traffic via IP-in-IP, hence allowing your computer to connect to any other Internet computer over any port via the error-corrected tunnel over the allowed port(s). This shows how and why the idea of trying to plug up the dangerous Internet via technological hacks like port filtering is basically a fool's errand. There is a technological race here, and the filtering will work for a while, which may be all that someone cares about, though.

torek
  • 448,244
  • 59
  • 642
  • 775