git port 22:Connection timed out

阅读量: 67 编辑

port 22:Connection timed out

Git 请求时,报 “ ssh:connect to host github.com port 22: Connection timed out ”

一、检查 SSH 和 秘钥配置

1、如果没有配置,信息中会给出具体的错误,比如说 “没有权限” 等。

2、如果你是因为修改了 GitHub 用户名,或者删除了 SSH Key。 那么可以将 .ssh 目录中(C:\Users\Administrator\.ssh)文件全部删除,直接重新配置即可。

3、如何配置,参考 本地配置SSH连接GitHub

二、添加config文件

如果以上都是OK的,可以尝试在 .ssh 目录中,添加 config 文件。

1、在 .ssh目录中,右键 ——》 Git Bash ,打开控制台 ——》 执行命令

vim config

然后按 i 键,输入内容如下:

Host github.com
User your_email@xx.com
HostName ssh.github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Port 443

然后按 esc,再按 :wq ,保存退出

2、然后执行命令

ssh -T git@github.com

即可完成配置。