git :Could not read from remote repository

本地(服务器)检查并生成ssh key

问题描述:

git仓库使用ssh方式连接,但是 push 或者pull的时候都提示:

 
  1. Permissiondenied (publickey).

  2.  
  3.   fatal:Could not read from remote repository.

  4.  
  5.   Pleasemake sure you have the correct access rights

  6.  
  7.   and the repository exists.

问题原因:

本地(或服务器)没有生成 ssh key。

解决方法

⚠️ 我的环境是 CentOS 7

1. 查看是否有文件id_rsa以及文件id_rsa.pub

cd ~/.ssh
ls

如果有id_rsa以及文件id_rsa.pub,则不是这个问题,另寻解决办法;

如果没有,继续

2. 生成ssh key

ssh-keygen -t rsa -C "[email protected]"

[email protected] 换成你自己的邮箱,一路回车,都不用管

最后成功会输出一个神秘矩阵包裹着重要信息(哈哈哈)

3. 生成成功之后, 在 ~/.ssh 目录下

cat id_rsa.pub

输出的就是 SSH KEY,复制出来添加到远程仓库的 公钥中或者其他操作

猜你喜欢

转载自blog.csdn.net/lmp5023/article/details/110946317
今日推荐