Yaonan Zhong

Yaonan Zhong

SSH to Github - operation timed out at port 22

Recently I got an error when tried to cloning a repository from Github server:

ssh: connect to host github.com port 22: Operation timed out

MyMac: Yaonan$ git clone git@github.com:zhongyn/zhongyn.github.io.git
Cloning into 'zhongyn.github.io'...
ssh: connect to host github.com port 22: Operation timed out
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

It seemed SSH was not working. So I used https clone URL instead and it did work.

But It is annoying that I had to enter GitHub username and password every time I used git fetch, git pull, or git push. Even though it is possible to use credential helper for remembering username and password under https, I still want to figure out what was wrong here. By trying many possible solutions, I fixed the bug by setting the firewall security after reading this article. My modem firewall was set to high security by accident and port 22 was blocked. It felt so good that I could use SSH again.