git Permission denied (publickey)

使用git命令克隆项目

git clone git@gitee.com:litongjava_admin/spring-boot-2.0.7-hello-jenkins.git

出现下面的错误

正克隆到 'spring-boot-2.0.7-hello-jenkins'...
The authenticity of host 'gitee.com (212.64.62.174)' can't be established.
ECDSA key fingerprint is SHA256:FQGC9Kn/eye1W8icdBgrQp+KkGYoFgbVr17bmjey0Wc.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'gitee.com,212.64.62.174' (ECDSA) to the list of known hosts.
git@gitee.com: Permission denied (publickey).
fatal: 无法读取远程仓库。

请确认您有正确的访问权限并且仓库存在。
root@litong-Inspiron-3458:~/dev_workspace/java/spring-boot# git ls-remote git@gitee.com:litongjava_admin/spring-boot-2.0.7-hello-jenkins.git
git@gitee.com: Permission denied (publickey).
fatal: 无法读取远程仓库。

请确认您有正确的访问权限并且仓库存在。

项目的git地址是
git协议地址

git@gitee.com:litongjava_admin/spring-boot-2.0.7-hello-jenkins.git

https协议地址

https://gitee.com/litongjava_admin/spring-boot-2.0.7-hello-jenkins.git

使用https克隆成功

git clone https://gitee.com/litongjava_admin/spring-boot-2.0.7-hello-jenkins.git

为什么使用https协议clone成功,使用git协议确实失败呢?

阅读 3.8k
2 个回答

git协议是基于ssh协议,如果使用git协议必须通过验证,如果想要通过验证必须将public key添加的git sever中

使用 .git 不行,是因为需要验证权限,你需要把你的公钥加到git 仓库就可以了。
使用 https 可以直接拉下来,不需要验证权限,但是你不能push ,push 的时候需要验证权限。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进