原文链接:

https://blog.csdn.net/weixin_40922744/article/details/107576748

问题描述:

在使用Git将本地仓库推送到远程仓库的时候,发生了如下错误:“fatal: Could not read from remote repository.”

问题原因:

出现这错误一般是以下两种原因:

  • 客户端与服务端未生成 ssh key
  • 客户端与服务端的ssh key不匹配

为解决以上问题,我们需要重新生成一次ssh key ,并重新配置一下GitHub账户即可。

解决步骤:(以下操作命令均在 Git Bash 中完成)

1. 生成新的SSH key

如果是客户端与服务端未生成ssh key,那么直接使用:

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

生成新的rsa密钥即可。

如果是客户端与服务端的ssh key 不匹配,此时需要先将本地生成的 id_rsa以及id_rsa.pub这两个文件【一般在用户名下的.ssh文件夹下】删除掉,然后再使用上述指令生成新的rsa密钥。

  • 补充:`ssh-keygen -t rsa -b 4096 -C "邮箱"``:这条命令的目的是为了让本地机器ssh登录远程机器上的GitHub账户无需输入密码。
ssh-keygen(基于密匙的安全验证):需要依靠密钥进行安全验证,必须为自己创建一对密钥,并把公用密钥放在需要访问的服务器上。
-t 即指定密钥的类型。密钥的类型有两种,一种是RSA,一种是DSA。
-b 指定密钥长度。对于RSA密钥,最小要求768位,默认是2048位。命令中的4096指的是RSA密钥长度为4096位。DSA密钥必须恰好是1024位(FIPS 186-2 标准的要求)。
-C 表示要提供一个新注释,用于识别这个密钥。“”里面不一定非要填邮箱,可以是任何内容,邮箱仅仅是识别用的key。

2. 将SSH key 添加到 ssh-agent

使用 ssh-add ~/.ssh/id_rsa 将产生的新ssh key添加到ssh-agent中:

  • 补充: 如果出现Could not open a connection to your authentication agent.的错误可以使用以下两种方式解决:
eval "$(ssh-agent -s)"

或者

eval `ssh-agent`

然后再次执行 ssh-add ~/.ssh/id_rsa 指令。

3. 将SSH key 添加到你的GitHub账户

在账户选项中选择 “Settings”–>“SSH and GPG keys”–>“New SSH key”,然后打开之前新生成的id_rsa.pub文件,将密钥复制后填写到账户中【注意填写时的格式要求】:

4. 验证key

使用 ssh -T git@github.com 对ssh key 进行验证:

当出现上述界面时说明配置成功,此时可以再次执行git push 操作将本地仓库推送到远程。

解决 “fatal: Could not read from remote repository.“的更多相关文章

  1. 解决码云未配置公钥问题——fatal: Could not read from remote repository.

    使用码云,键入“git push -u origin master” ,遇到如下问题: fatal: Could not read from remote repository.(致命:不能读远端仓库 ...

  2. git pull 出错 fatal: Could not read from remote repository.Please make sure you have the correct access rights.and the repository exists.

    Warning: Permanently added the RSA host key for IP address '192.30.252.131' to the list of known hos ...

  3. git提示错误关于错误:ssh: Could not resolve hostname github.com: Name or service not known.fatal: Could not read from remote repository.

    关于 Git 使用中出现的错误 饥人谷_楠柒 关注 2016.11.02 15:33* 字数 746 阅读 3607评论 5喜欢 10赞赏 1 关于错误:ssh: Could not resolve ...

  4. github Permission denied (publickey). fatal: Could not read from remote repository.

    github Permission denied (publickey).fatal: Could not read from remote repository. ----------------- ...

  5. Permission denied (publickey). fatal: Could not read from remote repository.

    博主在github上下载tiny face的的源代码的时候,遇到git clone命令为:git clone --recursive git@github.com:peiyunh/tiny.git 而 ...

  6. 用ssh进行git clone出现 fatal: Could not read from remote repository.

    问题:在通过MobaXterm进行ssh连接的服务器上用ssh进行git clone出现 fatal: Could not read from remote repository. 解决方法:prox ...

  7. fatal: Could not read from remote repository.

    fatal: Could not read from remote repository. Please make sure you have the correct access rightsand ...

  8. On branch master nothing to commit, working tree clean ERROR: Repository not found. fatal: Could not read from remote repository.

    将gitbash部署hexo到github:hexo deploy 报以下错误: Administrator@liu MINGW64 /Hexo $ hexo d INFO Deploying: gi ...

  9. github下载报错:Permission denied (publickey). fatal: Could not read from remote repository.

    Permission denied (publickey). fatal: Could not read from remote repository. 博主在github上下载tiny face的的 ...

  10. git之fatal: Could not read from remote repository

    问题背景:在git bash中使用hexo g -d命令进行文章发布 详细错误信息: fatal: Could not read from remote repository. Please make ...

随机推荐

  1. python中的platform模块

    platform模块给我们提供了很多方法去获取操作系统的信息: import platform print(platform.platform())# 获取操作系统名称和版本号:macOS-10.14 ...

  2. pgsql 数据库密码登录配置

    一.postgreSQL认证文件 pg_hba.conf 配置文件pg_hba.conf的位置,通常情况下的路径是 /etc/postgresql/[VERSION]/main/pg_hba.conf ...

  3. 解决uniapp 使用自带 switch 双向绑定视图不更新的问题

    使用  this.$set( a, b, c) a:需要更新视图属性对象 b:具体的属性值(就是你要更新视图的属性值) c:传递的参数 this.$set(this.gwjSelet,this.gwj ...

  4. 使用element上传图片的时候的限制只上传一个的问题

    <el-form-item label="轮播图图片" prop="image"> <el-upload class="avatar ...

  5. CSS3滤镜属性filter让网页变黑白

    很多特殊的时候,我们向英雄们致敬,在互联网上最常见的方式就是整个网页变黑白,今天逛某博客收集一段代码,用于网页整体变黑白,用css3滤镜属性filter让网页马上变黑白,一行代码就搞定. 在你的css ...

  6. jenkins +docker+python接口自动化之jenkins拉取gitee上的代码(四)

    1.背景 1.经过我们前面几轮的安装测试,我们已经安装了jenkins容器,python3,以及运行我们python代码所需要的第三方库在requirements.txt文件下统一安装. 2.需求 我 ...

  7. nchu第二次面向对象编程博客作业

    前言:   本次博客包含的内容有pta题目集4(四边形).5(五边形)以及期中考试三次题目集.其中第四次和第五次题目集难度较大,比较复杂,涉及的知识点也比较多.而期中考试由于是在课堂上完成,难度较小, ...

  8. 某星球存在两种生物,A种生物有1个头6条腿,B种生物有3个头4条腿。来自地球的太空船刚刚在该星球降落, 突然发现一大群这两种生物组成的队伍,由于时间紧,只数了头的数量和腿的数量,请帮助宇航员分析A、B两种生物各有多少个。

    package competition;import java.util.Scanner;/*        某星球存在两种生物,A种生物有1个头6条腿,B种生物有3个头4条腿.来自地球的太空船刚刚在 ...

  9. WSL2与ensp的40故障

    在使用ensp做radius认证的时候看到了Linux平台的freeradius认证服务器,于是使用了Windows平台的sub system: WSL2,按照网上的教程安装,并且安装了docker ...

  10. LoadRunner——block(块)技术

    一般情况下,loadrunner中的事务是统一执行的,多个事务所执行的次数是相同的,对于不同的事务执行不同的次数就要用到block(块)技术 block(块)技术主要应用于在一个脚本中实现不同事务.不 ...