今天在csdn的GitCode新建了一个项目,然后在windows下git clone时出现错误
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
完整报错如下图

直接说结论
因为没有把电脑的SSH public key添加到项目的git服务器上
操作如下
- 打开运行,输入services.msc,确定

- 找到 OpenSSH Authentication Agent 服务,需开启它,开启后如下图

- 打开cmd命令窗,执行 ssh-keygen -t rsa -C "你的邮箱地址"
如下图([email protected]是我的邮箱),中间会向你确认一些东西,一路回车即可

我用的是Administrator用户,执行完后,可以在 C:\Users\Administrator\.ssh 目录下生成 id_rsa 和 id_rsa.pub 这两个文件。如果你没有用Administrator用户,也是在类似的目录下
- 用记事本打开id_rsa.pub文件

把这个文件的全部内容复制出来,拷贝到你git项目的SSH Keys右侧的编辑框,如下图

最后点击下面的Add key按钮即可
- 再次用git clone 会发现已经可以了,这是我的效果图
