ssh: connect to host github.com port 22: Connection timed out
一直使用的ssh密匙来进行拉取和上传代码,突然有一天,Git说找不到我的密匙了,半夜三点啊把我急的,网上路子很多,以下是让我成功的解决方案,亲身帮你们避雷,如果以下方案都无法解决问题,那只要等等了,因为真的有无论如何也没法连上的情况,那应该是服务器端出现了某些问题,在此推荐两种方案:稍等片刻(3个小时吧),再次尝试;很急的话改用 https
吧。
- 前提
C:\Users\userName\.ssh
目录下是有公钥和秘钥文件的,没有的请去配钥匙,不然无法使用ssh加密。
- 缘由
->git pull
ssh: connect to host github.com port 22: Connection timed out
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
->ssh -T git@github.com
ssh: connect to host github.com port 22: Connection timed out
- 解决方案
C:\Users\userName\.ssh
目录下创建一个文件 config
,复制以下内容
Host github.com
User yourEmail
Hostname ssh.github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Port 443
里面需要改动内容只有yourEmail
!
- 测试
ssh -T git@github.com