Skip to content

Instantly share code, notes, and snippets.

@Tamal
Last active May 9, 2025 19:59
Show Gist options
  • Save Tamal/1cc77f88ef3e900aeae65f0e5e504794 to your computer and use it in GitHub Desktop.
Save Tamal/1cc77f88ef3e900aeae65f0e5e504794 to your computer and use it in GitHub Desktop.
Solution for 'ssh: connect to host github.com port 22: Connection timed out' error
$ 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.
@Fynchina
Copy link

when i put this line [vim ~/.ssh/config] into my terminal , my terminal stopped working and i can’t run any other line

@khatrig
Copy link

khatrig commented Jul 20, 2022

@mohammad-hassani
Copy link

also if it did not work and the output was :

Bad owner or permissions on /home/poparent/.ssh/config

just run this command:

chmod 600 ~/.ssh/config

@RedisOptimal
Copy link

谁能解释为什么会发生此错误?GitHub 是否要求您使用端口 443 进行 ssh 访问?

ssh: connect to host github.com port 22: Network is unreachable
fatal: Could not read from remote repository.

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

(Hope it works for you) Me too, so I gave up this method and tried another thing: image

It works!!

@derickpambah
Copy link

Thank you so much. It worked out for me.

@mossplix
Copy link

mossplix commented Aug 6, 2022

Thank you!

@benben2019
Copy link

It worked ! Thank you !

@MingzXIE
Copy link

Thank you so much

@bathindahelper
Copy link

How can we gain ssh/shell access so that we could push changes back to github repositories? (I work on windows ubuntu bash terminal)

@MideMait
Copy link

THANK YOU THANK YOU THANK YOU

@vipranarayan14
Copy link

vipranarayan14 commented Aug 28, 2022

This also works for connection refused error. Thank you.

@Tapaswini98
Copy link

Thank you

@chewthemonkey
Copy link

Thanks!

@NathOrmond
Copy link

Thanks! The port was also an issue for me and this resolved it

@nwaweru
Copy link

nwaweru commented Sep 16, 2022

THANK YOU!!

@backup01
Copy link

Thank you, Tamal! I spent on it few hours, before i found your solution.

@dteok
Copy link

dteok commented Sep 27, 2022

Thank you! Editing ~/.ssh/config works just fine for me

@Mick777777
Copy link

also if it did not work and the output was :

Bad owner or permissions on /home/poparent/.ssh/config

just run this command:

chmod 600 ~/.ssh/config

This works for me!

@clknap
Copy link

clknap commented Oct 6, 2022

Thank you Tamal !
Adding the port to ssh config fixed the issue for me (Monterey 12.6)

@hobo1618
Copy link

hobo1618 commented Oct 9, 2022

worked perfectly, thank you!

@cristianvargasxmarts
Copy link

thanks

@gherlein
Copy link

anyone know why this actually works?

@mirinda123
Copy link

thank you so much!

@givi-jalaghania
Copy link

Host github.com
Hostname ssh.github.com
Port 443
what should i do after typing it in?
I am new to github

@Yanis02015
Copy link

After 3 hours of hard work, I found this nugget! THANK YOU

@chaoszhang
Copy link

Thank you!

@AitorSantaeugenia
Copy link

AitorSantaeugenia commented Nov 1, 2022

This is not working for me.
ssh -T git@github.com -> ssh: connect to host github.com port 22: Connection timed out
ssh -T -p 443 git@ssh.github.com -> ssh: connect to host ssh.github.com port 443: Connection timed out

If I push using the same ssh keys with a program like SmartGit (for Ubuntu, and it ask for the ssh key so I just add them and the passphrase), I CAN push using that program.

I really don't understand why I can't push with cmd...

Anyone knows what is happening?.

@nedith
Copy link

nedith commented Nov 2, 2022

After hours of searching for a solution, this has worked for me!!! Thank you so much!

@kennyxiao0314
Copy link

It also works for me, but I want to konw why it must be this?

@Alvan-Judi
Copy link

You are my savior .... 3hours on it, testing everything and nothing worked !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment