Github克隆项目的时候报错:git@github.com: Permission denied (publickey).解决方法

问题

Github克隆项目的时候报如下错:

git@github.com: Permission denied (publickey).

fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

从上面报出的错误提示可以知道在克隆项目时没有权限所以被拒绝了,Github 服务器和我们本地的通讯要使用 SSH key(密钥)来验证,去我们Github主页检查是否缺少密钥,缺少了密钥只需设置一个密钥就行了。

 

 

解决方法

从Github主页右上角点击头像选择Settings,点击进入SSH and GPG keys

                                       

 

 

 点击创建一个新的密钥"New SSH key"

 

SSH Key获取方法

打开 Git Base,输入命令:ssh-keygen -t rsa -C ‘emailXXXX@example.com’,然后一直回车,注意:有y/n是输入y,下图中这个y/n就是已经有文件项目询问是否覆盖的意思。

 

 

 

 

 接下来输入命令:cat ~/.ssh/id_rsa.pub

 这个时候显示出密钥,然后直接复制密钥粘贴到GitHub设置密钥SSH的key上面然后保存即可。

posted @ 2020-04-15 00:07  Leo~Chan  阅读(2182)  评论(0编辑  收藏  举报