GitHub推送代码至远程仓库或远程仓库拉取代码到本地,突然报错ssh: connect to host github.com port 22: Connection refused
·
GitHub推送代码至远程仓库或远程仓库拉取代码到本地,突然报错ssh: connect to host github.com port 22: Connection refused
导火索
之前都一直能够正常与远程仓库交互,可以正常拉取代码和推送代码到远程仓库,突然今天工作前需要先拉取远程代码看一下有没有更新时,输入命令后,直接报错ssh: connect to host github.com port 22: Connection refused
//报错内容,无论是拉取还推送都是这个错
ssh: connect to host github.com port 22: Connection refused
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
原因
网络原因导致22端口被禁止访问,也就说无法访问github对应的22端口,22端口被禁止访问了
解决方案
既然22端口被禁用了,那么咱就使用443端口呗,还更好,使用了加速器的,不会和网页端的冲突。用22端口时,使用了加速器,与远程仓库必须先关闭加速器,才能交互。一但使用443端口,无需任何操作,不需要关闭加速器,就可以直接交互。
windows系统下
# 使用 PowerShell 创建配置文件
Add-Content -Path ~/.ssh/config -Value @"
Host github.com
Hostname ssh.github.com
Port 443
User git
"@
//执行完上述命令后,测试一下是否可以连通
# 测试 SSH 连接(应该返回成功信息)
ssh -T git@github.com
更多推荐
所有评论(0)