【git】ssh: connect to host github.com port 22: Connection refused fatal: Could not read from remote r

这篇具有很好参考价值的文章主要介绍了【git】ssh: connect to host github.com port 22: Connection refused fatal: Could not read from remote r。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

之前github的ssh的公私钥已经配置好,并可以正常使用,可没过多久,有一天突然报错:

ssh: connect to host github.com port 22: Connection refused fatal: Could not read from remote repository.

原因

git 远程仓库两种协议:ssh,https。
在解决问题之前,先要了解git远程仓库的两种协议连接。

ssh连接github方法

ssh协议连接github
1.在git的命令行,输入

$ ssh-keygen -t rsa -C "youremail@example.com"

然后就会在用户的.ssh下生成了两个SSH Key的秘钥对,
id_rsa是私钥,不能泄露出去,id_rsa.pub是公钥

2.将公钥配置在github上
设置里找到👇

ssh: connect to host github.com port 22: connection refused,编程笔记(问题解决),部署&Linux运维,git,ssh,github

打开本地的id_rsa.pub(公钥),将内容复制进去即可。

3.github端配置完毕后,看本地的git 如何添加远程仓库:

第一步,查看当前git的远程仓库版本:

 git remote -v

此时若什么都没有显示说明,git无远程仓库。

第二步,添加ssh协议的远程仓库:

 git remote add origin git@github.com:Itfuture-zifeiYu/ZifeiChat.git 

4.再次输入git remote -v 查看

$ git remote -v
origin  git@github.com:Itfuture-zifeiYu/ZifeiChat.git (fetch)
origin  git@github.com:Itfuture-zifeiYu/ZifeiChat.git (push)

说明连接成功!

问题解决方案

出现报错是使用ssh协议,很明显,ssh协议可能被禁掉了(原因可能是公私钥失效,泄露,或者当前所在网络限制等),只能换一种连接进行合并本地仓库了。继续往下看另一种协议。

切换成 https协议连接github

1.移除掉远程仓库的配置:

git remote rm origin

2.重新添加新的远程仓库,以https的形式:

git remote add originhttps://github.com/Itfuture-zifeiYu/ZifeiChat.git

再次查看:

$ git remote -v
origin  https://github.com/Itfuture-zifeiYu/ZifeiChat.git (fetch)
origin  https://github.com/Itfuture-zifeiYu/ZifeiChat.git (push)

再次尝试pull代码,成功!文章来源地址https://www.toymoban.com/news/detail-806480.html

到了这里,关于【git】ssh: connect to host github.com port 22: Connection refused fatal: Could not read from remote r的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • git报错处理:ssh:connect to host github.com port 22: Connection timed out

    git 在上传、下载 文件的时候,报错。 报错信息: ssh:connect to host github.com port 22: Connection timed out 提示这个域名github.com port 的22 端口,链接超时。 我直接访问github.com 这个域名是可以访问的,ping 也是可以ping通的。 使用telnet 链接github.com 的22 端口,报超时错误。 所以,问题

    2024年02月11日
    浏览(17)
  • Git提交 ssh: connect to host github.com port 22: Connection timed out解决方案

    你们好,我是金金金。 之前都是好好的,不知道今天为什么提交代码就这样了 根据英文可以看出,ssh端口号被拒绝了,22号端口不行,那就换一个端口 ssh端口被拒绝 找到.ssh文件,在下面创建一个config文件,然后记事本打开写入以下内容 成功提交 主要是ssh 22端口被拒绝,我

    2024年01月22日
    浏览(29)
  • 【git】解决git报错:ssh:connect to host github.com port 22: Connection timed out 亲测有效

    如题,git使用中突然报错 ssh:connect to host github.com port 22: Connection timed out 通过查阅各种资料,得知原因可能是由于电脑的防火墙或者其他网络原因导致ssh连接方式 端口22被封锁。 创建一个config文件 将下面的内容复制进去 保存退出 检查是否成功 这里要根据它的提示操作,有个

    2024年02月05日
    浏览(26)
  • 【Git 教程系列第 27 篇】ssh: connect to host github.com port 22: Connection refused 的解决方案

    这是【Git 教程系列第 27 篇】,如果觉得有用的话,欢迎关注专栏。 一:问题描述 自己的一个 git 项目,昨天在公司正常 push 的时候,提示文字信息如下 提示截图信息如下 有人说是因为开了代理的原因,不过之前我开着代理提交是没有问题的,但还是试了一试,可惜并没有

    2024年02月08日
    浏览(19)
  • 解决 Git:ssh: connect to host github.com port 22: Connection timed out 问题的三种方案

    其一、整体提示为: ssh: connect to host github.com port 22: Connection timed out fatal: Could not read from remote repository. 中文为: ssh:连接到主机 github.com 端口 22:连接超时 fatal:无法从远程存储库读取 其二、问题描述为: A、正常的将代码提交到 git 仓库的过程: step1、找到要提交 git 的代

    2024年01月25日
    浏览(28)
  • 终极办法!connect to host port 22: Connection timed out git@ssh.github.com: Permission denied (publickey

    过了个周末git突然用不了了,在拉代码的时候突然报错连接超时,又报错说没有权限,这就很烦了 在百度了很久以后尝试了各种办法,重新生成pub_key,重装git等等都没能解决,最后询问了公司大佬,困扰了一个上午的问题终于解决了 先说说百度上的解决办法: 使用命令 s

    2024年02月04日
    浏览(25)
  • ssh: connect to host github.com port 22: Connection refused

    最近使用 git 拉取 Github 上的项目时老是出现 Connection refused : 网上的解决办法 解决ssh: connect to host github.com port 22: Connection refused 但是在使用了这个方法后依然无法解决: 然后看见隔壁工位上大哥的搜索栏上赫然也是这个问题,交流一番应该是最近墙比较敏感的问题。 解决方

    2024年02月13日
    浏览(18)
  • 解决ssh: connect to host github.com port 22: Connection refused

    ssh: connect to host github.com port 22: Connection refused 是连接github.com的端口号22拒绝连接。 可以使用github的443端口。 解决方案 在 ~/.ssh/config 中添加如下字段: 测试是否链接成功 如果出现如下字段则验证成功 The authenticity of host ‘[ssh.github.com]:443 ([20.205.243.160]:443)’ can’t be establishe

    2024年01月22日
    浏览(24)
  • 如何解决:ssh: connect to host github.com port 22: Connection refused

    问题: 进行github操作时出现了下面的错误,如何解决   排查思路: ssh: connect to host github.com port 22: Connection refused  这个错误提示的是连接 github.com 的22端口被拒绝了。可以简单理解为此门不通,既然这个端口号走不通,那换一个端口号试试看。 解决方法一: 网上大多的解决

    2024年02月14日
    浏览(19)
  • 【git】ssh: connect to host github.com port 22: Connection refused fatal: Could not read from remote r

    之前github的ssh的公私钥已经配置好,并可以正常使用,可没过多久,有一天突然报错: ssh: connect to host github.com port 22: Connection refused fatal: Could not read from remote repository. git 远程仓库两种协议:ssh,https。 在解决问题之前,先要了解git远程仓库的两种协议连接。 ssh协议连接gi

    2024年01月20日
    浏览(22)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包