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.
上面的问题是说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]-----+
然后使用命令
vim /Users/hubinnn/.ssh/id_rsa.pub
打开你的ssh key,然后复制到你的GitHub中的SSH KEY
如下图:
在GitHub上添加了自己的SSH KEY。然后再运行一次;
root$ git clone git@github.com:XXXXX/XXXXX.git