Git22端口连接超时问题

问题描述

将博客推送到云服务器和github pages时报错

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

fatal: Could not read from remote repository.”

image-20240130215000994

问题分析

中文为:
ssh:连接到主机 github.com端口22:连接超时

fatal:无法从远程存储库读取

1
ssh -vT git@github.com

image-20240130220147271

测试无法连接

1
ssh -T -p 443 git@ssh.github.com

image-20240130220750026

443端口测试没问题,22端口被占用了或者某些网络可能会阻塞ssh的默认的22端口,换网络或者科学上网可能可以解决。当然也可以考虑永久地更改你的ssh配置以使用443端口!!!

问题解决

在**.ssh**文件夹中新建文本文件config。(该文件夹下还存有id_rsa id_rsa.pub known_hosts三个文件,如有请进行下一步)。

1
cd ~/.ssh
1
vim config

输入以下内容,保存后即可,其中xxx@qq.com为你自己的邮箱

1
2
3
4
5
6
Host github.com
User xxx4@qq.com
Hostname ssh.github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Port 443

image-20240130221259348

再次测试连接以及推送 都没有问题。

image-20240130221926325

image-20240130221944895

富婆 饿饿 饭饭
0%