git clone 出错 “Permission denied (publickey)” 解决办法

运行命令 git clone [email protected]:robbiehanson/CocoaAsyncSocket.git 时出错如下:

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

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

解决办法:

  1. 在Git Bash输入命令: ssh-keygen -t rsa -C <添加注释,可省略>
  2. 操作成功后会在当前用户文件下面会生成一个.ssh文件夹,如:C:\Users\vance\.ssh,在.ssh文件夹里面有三个文件:id_rsaid_rsa.pubknown_hosts。其中id_rsa是私钥文件,id_rsa.pub是公钥文件,打开公钥文件后复制;
  3. 进入github个人设置页面,左边选择“SSH and GPG keys”,右边点击“New SSH key”,Key中粘贴刚才复制的公钥文件里面的内容,然后保存就可以正常使用git clone [email protected]:robbiehanson/CocoaAsyncSocket.git命令。

注: ssh-keygen 命令

你可能感兴趣的:(git clone 出错 “Permission denied (publickey)” 解决办法)