github 端口22 超时问题解决

github 端口22 超时问题解决

问题描述

搬了个公司后发现自己的sourcetree 以及 本地命令行在拉取代码或者clone时均报错,根据网友的解决方案,做了个整理

报错信息

复制代码
$ git pull project develop
ssh: connect to host github.com port 22: Connection timed out
fatal: Could not read from remote repository.

解决方案

使用 ssh 443端口

步骤1

测试端口443是否可用 注意必须存在一个 ssh (如无 请使用命令ssh-keygen -t ed25519 -C "your_email@example.com" 生成,并在github ssh设置中添加),以用于测试

在git命令行中敲入

复制代码
ssh -T -p 443 git@ssh.github.com

步骤2

编辑.ssh 下的config文件,如无直接创建即可

复制代码
Host github.com
Hostname ssh.github.com
Port 443

多ssh的配置config例子如下

复制代码
Host github.com
  Hostname ssh.github.com
  Port 443

Host github.com
  HostName ssh.github.com
  Port 443
  IdentityFile C:\Users\Administrator\.ssh\id_ed25519
  PreferredAuthentications publickey

Host github.com
  HostName ssh.github.com
  Port 443
  IdentityFile C:\Users\Administrator\.ssh\id_peter
  PreferredAuthentications publickey

步骤3

不指定端口进行测试,此时你可以通过SourceTree等进行正常访问

复制代码
ssh -T git@github.com
相关推荐
foundbug9996 小时前
查看nginx日志文件
linux·nginx·github
whysqwhw7 小时前
使用Wire 基于 KMP实现imdk
github
whysqwhw7 小时前
wire 库介绍
github
绝无仅有8 小时前
某大厂跳动Java面试真题之问题与解答总结(五)
后端·面试·github
绝无仅有8 小时前
某大厂跳动Java面试真题之问题与解答总结(四)
后端·面试·github
逛逛GitHub9 小时前
推荐 2 个 GitHub 上集成 Nano banana 的开源项目。
github
拐爷老拐瘦9 小时前
TalkReplay:把你的 AI 对话,变成可复盘、可分享的生产力
github
FreeBuf_11 小时前
GitHub Copilot 提示注入漏洞导致私有仓库敏感数据泄露
github·copilot
cmdyu_11 小时前
国内如何升级GitHub Copilot到专业版
github·copilot·ai编程
吃饺子不吃馅13 小时前
小明问:要不要加入创业公司?
前端·面试·github