QA|Pycharm update时报错ssh: connect to host github.com port 22: Connection timed out|GIT

发布时间 2023-09-20 15:52:15作者: T-Better

场景:

另一台电脑很久没有链接Github了,今天执行update失败,报错如下:

2023/9/20
15:09    Update failed
            Funny_Scripts and Spider: Connection reset by 20.205.243.166 port 22
            Could not read from remote repository.
            
            Please make sure you have the correct access rights
            and the repository exists.
            SoftTest: ssh: connect to host github.com port 22: Connection timed out
            Could not read from remote repository.
            
            Please make sure you have the correct access rights
            and the repository exists.

 

确认问题:

使用git bash执行ssh -T git@github.com,发现报错ssh: connect to host github.com port 22: Connection timed out

 

查资料解决:

  1. 在C盘——用户——你的主机名文件夹中找到.ssh文件夹;(此前配置SSH时会生成该文件夹)
  2. 在.ssh文件夹中新建文件 config,不带后缀(可以新建文本文档,去掉.txt后缀)
  3. 打开config文件,输入以下内容,保存
Host github.com
User YourEmail(你的邮箱)
Hostname ssh.github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Port 443

  

 

再次执行:ssh -T git@github.com

会出现以下提示,输入yes回车即可

The authenticity of host '[ssh.github.com]:443 ([192.30.255.123]:443)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[ssh.github.com]:443,[192.30.255.123]:443' (RSA) to the list of known hosts.

 再次执行:ssh -T git@github.com,即可连上了

 此时在PYCHARM上执行update即可成功更新了

 

原因分析:

报错是ssh链接超时,而后面在config中重新定义了ssh所使用的端口,也就是说默认端口22被占用了,重新配置一个即可

 

参考文章:

ssh: connect to host github.com port 22: Connection refused - 知乎 (zhihu.com)

Git问题:解决“ssh:connect to host github.com port 22: Connection timed out”_ssh: connect to host github.com port 22: connectio_秦时明月之君临天下的博客-CSDN博客