4

I've scoured the internet and found many people with similar problems, but my variant seems to be unique. The issue is I cannot connect to GitHub via ssh in order to push/pull (I'm on Windows 10).

If I run ssh -T [email protected]:

ssh: connect to host github.com port 22: Network is unreachable

If I run ssh -T -p 443 [email protected]:

Hi cjriches! You've successfully authenticated, but GitHub does not provide shell access.

Bizarrely, if I run ssh -T [email protected]:

Welcome to GitLab, @cjriches!

This, combined with the fact that I tried disabling Windows Firewall to no avail, seems to prove that it's not just port 22 that's the problem. For what it's worth, I can also SSH into other, completely non-git-related hosts. For some reason, it's GitHub specifically that refuses to connect. I've re-uploaded the public key just in case, so the problem definitely isn't there.

Has anybody got any ideas how on earth this could be happening?

1
  • 1
    Try to use ssh with -vvv, check if the domain is resolved to a correct ip. Are there any other problems/warnings in the log? Commented Dec 19, 2019 at 5:52

5 Answers 5

6

Seems like it is either a DNS issue or a Proxy issue. I would try changing my dns to 8.8.8.8 and 8.8.4.4. See if that clears up the issue. If that still doesn't rectify the issue, I would look and see if I am using a proxy which is preventing me from contacting github.

Sign up to request clarification or add additional context in comments.

1 Comment

Changing DNS server fixed the issue. Verbose SSH output showed that with my default (Virgin Media) DNS, github.com was resolving to 81.99.162.48, which is the address of a VM proxy server. Using Google's DNS as suggested resolved it to 140.82.118.3, which is owned by GitHub and worked correctly. From this link, it appears that Virgin Media Websafe for some reason doesn't play nicely with GitHub; the issue could also be fixed by adding github.com to its whitelist, but I'm not in a position to do that.
6

I had the same issue. Solve it by disabling the Virus Safe and Child Safe in the "Manage my Web Safe settings" section in the virgin broadband account page.

Source: https://community.virginmedia.com/t5/Forum-Archive/GitHub-inaccesible-over-SSH/td-p/3816287

2 Comments

As mentioned in my comment on the accepted answer, this is indeed the root cause of the problem. You can either disable those settings as you say, or change DNS servers to bypass them as the other answer suggests.
I have disabled but still have the issue, does it take time for the setting to take hold. The thing is, I have been on Virgin for years, but this problem literally started yesterday for me.
1

Thanks to the OP and the other answers. My solution was to edit my ~/.ssh/config file (on linux).

Host github.com
HostName 140.82.121.4
User git
AddKeysToAgent yes
# Linux does not recognise UseKeychain but Mac does
IgnoreUnknown UseKeychain 
UseKeychain yes
IdentityFile ~/.ssh/your_ssh_key_file

Comments

0

Check git config --show-origin -l to see if there is any setting (proxy or others) that might apply to github.com specifically.

And check your environment variables ('set' in a CMD in Windows), also to double-check if any of those variables might involves GitHub.

Comments

0

My solution was to enable SSH connections over HTTPS. See GitHub docs for more information.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.