当前位置:   article > 正文

【ssh】解决port 22:connection time out_port 22: connection timed out

port 22: connection timed out

突然git clone报错了,之前没遇到过,记录一下

报错信息:

  1. ssh: connect to host github.com port 22: Connection timed out
  2. Please make sure you have the correct access rights
  3. and the repository exists.

运行以下命令检查ssh是否能够连接成功

ssh -T git@github.com

报错:

  1. $ ssh -vT git@github.com
  2. OpenSSH_9.2p1, OpenSSL 1.1.1t 7 Feb 2023
  3. debug1: Reading configuration data /etc/ssh/ssh_config
  4. debug1: Connecting to github.com [20.205.243.166] port 22.
  5. debug1: connect to address 20.205.243.166 port 22: Connection timed out
  6. ssh: connect to host github.com port 22: Connection timed out

这个错误消息表明计算机无法通过 SSH 连接到 GitHub。 "Connection timed out" 意味着连接超时。

检查一下是否添加了SSH密钥

cat ~/.ssh/id_rsa.pub

输出显示已经配置密钥了。

查阅资料后,解决问题方案如下:

在 C:\Users\Username\.ssh 目录下,新建config文件,内容如下:

 

  1. Host github.com
  2. User xxx@xxx.com(你的邮箱)
  3. Hostname ssh.github.com
  4. PreferredAuthentications publickey
  5. IdentityFile ~/.ssh/id_rsa
  6. Port 443

配置完成后,再次执行ssh -T git@github.com
输出如下,输入yes即可

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

再次运行ssh -T git@github.com就连接上了

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/613410
推荐阅读
相关标签
  

闽ICP备14008679号