-
Star
(545)
You must be signed in to star a gist -
Fork
(124)
You must be signed in to fork a gist
-
-
Save Tamal/1cc77f88ef3e900aeae65f0e5e504794 to your computer and use it in GitHub Desktop.
$ git clone git@github.com:xxxxx/xxxx.git my-awesome-proj | |
Cloning into 'my-awesome-proj'... | |
ssh: connect to host github.com port 22: Connection timed out | |
fatal: Could not read from remote repository. | |
$ # This should also timeout | |
$ ssh -T git@github.com | |
ssh: connect to host github.com port 22: Connection timed out | |
$ # but this might work | |
$ ssh -T -p 443 git@ssh.github.com | |
Hi xxxx! You've successfully authenticated, but GitHub does not provide shell access. | |
$ # Override SSH settings | |
$ vim ~/.ssh/config | |
``` | |
# Add section below to it | |
Host github.com | |
Hostname ssh.github.com | |
Port 443 | |
``` | |
$ ssh -T git@github.com | |
Hi xxxxx! You've successfully authenticated, but GitHub does not | |
provide shell access. | |
$ git clone git@github.com:xxxxxx/xxxxx.git my-awesome-proj | |
Cloning into 'my-awesome-proj'... | |
remote: Enumerating objects: 15, done. | |
remote: Counting objects: 100% (15/15), done. | |
remote: Compressing objects: 100% (14/14), done. | |
remote: Total 15 (delta 0), reused 15 (delta 0), pack-reused 0 | |
Receiving objects: 100% (15/15), 22.90 KiB | 4.58 MiB/s, done. |
Thanks~ It worked for me
For the people that have tried all the above solutions and none of them have worked: It may be a DNS resolution problem. I'm working from a WSL instance in Windows 11 Pro. Here are few things you can try to check if it is a DNS resolution issue:
dig ssh.github.com
dig google.com
ping google.com
If none of the above commands works, e.g. for the dig google.com
this would be a good output:
; <<>> DiG 9.18.12-0ubuntu0.22.04.1-Ubuntu <<>> google.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 25537
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;google.com. IN A
;; ANSWER SECTION:
google.com. 300 IN A 216.58.208.110
;; Query time: 40 msec
;; SERVER: 8.8.8.8#53(8.8.8.8) (UDP)
;; WHEN: Sat Jul 22 11:52:38 CEST 2023
;; MSG SIZE rcvd: 55
And this would be a bad output:
;; communications error to 172.24.128.1#53: timed out
The same applies to the dig ssh.github.com
command.
If you are getting the timed out outputs of the dig commands, next step is to check the /etc/resolv.conf
file
Mine was pointing out to an unreachable nameserver and thus name resolution wasn't being possible.
# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateResolvConf = false
nameserver 172.24.128.1
I added Google's nameserver (you can add any nameserver of your preference)
# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateResolvConf = false
# nameserver 172.24.128.1
nameserver 8.8.8.8
nameserver 8.8.4.4
Save the file (remember to edit it as sudo) and try the dig command again. If you get the good output, the issue was the unreachable nameserver. If you still get a timed out output in the dig command there might be a problem with the port 53 in your network. I cannot provide further information as my issue was the nameserver.
After solving the nameserver issue the command ssh -T git@ssh.github.com
and any domain related command should work beautifully now.
I found this article is very useful. I got more ideas about how to fix this issue. https://www.howtouselinux.com/post/ssh-connect-to-host-port-22-connection-timed-out
I have been trying to fix still Im getting stuck
hope@hope-HP-ProBook-450-G2:~$ ssh -T git@github.com kex_exchange_identification: Connection closed by remote host Connection closed by 185.199.108.153 port 443
please help me
I'm getting same issue :(
ssh -T -p 443 git@ssh.github.com
kex_exchange_identification: Connection closed by remote host
Connection closed by 20.201.28.152 port 443
@junglejf I think you can use curl -v telnet://ssh.github.com:443 to test your network connectivity to github. if the connection is not connected, you need to check this on the network side. if it shows like below, it means the network connection is good. You can check your ssh key file.
% curl -v telnet://ssh.github.com:443
* Trying 140.82.113.35:443...
* Connected to ssh.github.com (140.82.113.35) port 443 (#0)
ssh -T -p 443 -i /path/your/private/key git@ssh.github.com
It worked thank you!
<3
after putting the lines that you tell me how to close the file and save it
after putting the lines that you tell me how to close the file and save it
after putting the lines that you tell me how to close the file and save it
I found it is a lot more easier to save if you used microsoft visual code to open ~/.ssh/config
. So I opened using code ~/.ssh/config
. Then I overwrote this inside config file. Finally it worked.
works for me, thanks!
Worked perfectly to me on Debian 10. Thank you so much!
it worked! thank you!
Thank you.
Thanks~ It worked for me
Host github.com
Hostname ssh.github.com
User xiaoxinmiao
Port 443
IdentityFile /c/Users/Administrator/.ssh/github
Thanks!
Thank you so much, you saved my day!
Thank you
Thanks alot! it worked.
Thanks god I was able to google this gist
THANK YOU
THANK YOU SO MUCH IT WORKED ..... AFTER 3HOUR OF HUSSLE ..... THANK YOU REALLY
it's work for me
if you don't get the expected result, then perform another option via the command line:
git config http.sslVerify false
Thank you so much!!!! I've been struggling for days for this
Thanks u so much bro
Thank you! It works!
this works to me, thanks a million
thank you very much, works for me as well.
Nice!! it works perfectly
great job ,thanks .