git clone警告,提示Warning:Permission denied (publickey)

git clone git@github.com:***
//提示
正克隆到 'pose-hg-train'...
Warning: Permanently added the RSA host key for IP address '一个IP地址' to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.

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

当从终端克隆一个git项目时

  • 1.首先你要有一个github账号
  • 2.明白公钥问题

  可自行百度,以下是我理解的

  公钥就像是我的银行卡卡号,我把我的卡号(公钥)给别人,别人才能往我的卡号里存钱(信息用公钥加密后发送给我),但是只有我自己有银行卡密码(私钥),只有我自己能够取钱(破解信息)。

  • 3.找到自己电脑的公钥
    • 先去查看是否生成过公钥
    • cd ~/.ssh/
      文件夹下如果有文档id_rsa.pub,且里面有公钥 则不用重新生成公钥,否则执行
    • ssh-keygen

          生成公钥打开本地~/.ssh/id_rsa.pub 复制公钥

  • 4.把公钥给github,让他认识你的电脑
    • 登录github打开设置Settings
    • 选择SSH and GPG keys
    • 选择右上角New SSH key
    • Title中起一个名字,方便自己区分是哪里的公钥,复制刚才的公钥到Key里,添加成功后再执行git clone则会成功。以后也可以一直使用。

  

 

 

 

posted @ 2019-12-10 16:19  MengDi  阅读(616)  评论(0编辑  收藏  举报