当前位置:   article > 正文

GitHub Clone项目时出现的问题(Permission denied (publickey))_githubclone时出现per

githubclone时出现per

GitHub Clone项目时出现的问题

在使用git在本地clone远程Github上的项目时

root$ git clone git@github.com:XXXXX/XXXXX.git
...
Warning: Permanently added the RSA host key for IP address '52.74.223.119' to the list of known hosts.
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.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

上面的问题是说Github中无法感知到你本地的SSH KEY。此时你需要在本地生成一个ssh key。然后在你的gitHub的setting中保存起来。

下面是本地生产ssh key的过程:下列邮箱地址最好写成你的git config user.email,输入完命令之后,回车三次会出现生成的ssh key的路径 /Users/hubinnn/.ssh/id_rsa.pub。注意:在Mac的终端下、在按回车的时候,可能会出现输入你的管理员密码的情况,不用慌张,安静输入~

root$ ssh-keygen -t rsa -C "hub~~~~@gmail.com" 
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/hubin/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /Users/hubinnn/.ssh/id_rsa.
Your public key has been saved in /Users/hubinnn/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:y1PcLwhQPoX4N35Dl4RdQT0EN7dsadasdasdE62Jz13fXE hub~~~~@gmail.com
The key's randomart image is:
+---[RSA 2048]----+
|       ....+ ++OE|
|      .o..+ * +.O|
|      ..o  = * **|
|       ..oo.+ X *|
|        Sooo.. = |
|       . +..o.  .|
|        + .....  |
|         .   .   |
|                 |
+----[SHA256]-----+
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21

然后使用命令vim /Users/hubinnn/.ssh/id_rsa.pub打开你的ssh key,然后复制到你的GitHub中的SSH KEY

如下图:
打开GitHub的设置页
进入到SSH KEYS,然后NEW SSH KEY
在这里插入图片描述

在GitHub上添加了自己的SSH KEY。然后再运行一次;
root$ git clone git@github.com:XXXXX/XXXXX.git

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/476691
推荐阅读
相关标签
  

闽ICP备14008679号