Could not read from remote repository.Please make sure you have the correct access rights.and the repository exists.

使用git clone命令从github上同步github上的代码库时,如果使用SSH链接(如我自己的esesgrid项目:git@github.com:hmilycc/esesgrid.git),而你的SSH key没有添加到github帐号设置中,系统会报下面的错误:

Permission denied (publickey).

fatal: Could not read from remote repository.

Please make sure you have the correct access rights

and the repository exists.

这时需要在本地创建SSH key,然后将生成的SSH key文件内容添加到github帐号上去。创建SSH key的方法很简单,生成ssh key的过程如下图所示:

《Could not read from remote repository.Please make sure you have the correct access rights.and the repository exists.》

然后系统提示输入文件保存位置等信息,连续敲三次回车即可,生成的SSH key文件保存在中~/.ssh/id_rsa.pub文件中。

然后用文本编辑工具打开该文件,在linux下可以用cat命令显示id_rsa.pub中的内容(cat  ~/.ssh/id_rsa.pub),让后复制其内容;如果在linux下,也可以直接使用记事本打开该文件,但一定要注意其内容中包含空格和换行,要将其去掉。

接着拷贝.ssh/id_rsa.pub文件内的所以内容,将它粘帖到github帐号管理中的添加SSH key界面中。

打开github帐号管理中的添加SSH key界面的步骤如下:

1. 登录github

2. 点击右上方的Accounting settings图标

《Could not read from remote repository.Please make sure you have the correct access rights.and the repository exists.》

3. 选择 SSH key

《Could not read from remote repository.Please make sure you have the correct access rights.and the repository exists.》

4. 点击 Add SSH key

在出现的界面中填写SSH key的名称,填一个你自己喜欢的名称即可,然后将上面拷贝的~/.ssh/id_rsa.pub文件内容粘帖到key一栏,在点击“add key”按钮就可以了。

参考:http://blog.sina.com.cn/s/blog_53786db50102e9ma.html

    原文作者:snail小菜
    原文地址: https://www.jianshu.com/p/428bded87ef3
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞