1、问题简述
提交代码远程仓库报错
Git@gitee.com: Permission denied (publickey). Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
或者添加仓库地址时候报错
Git@gitee.com: Permission denied (publickey). Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
2、解决办法
在Android studio项目根目录右键选择Git Bash Here
输入
ssh-keygen -t rsa -C "xxxxx@xxxxx.com"
# Generating public/private rsa key pair...
# 三次回车即可生成 ssh key
查看你的 public key,并把他添加到码云(Gitee.com) SSH key添加地址:https://gitee.com/profile/sshkeys)
cat ~/.ssh/id_rsa.pub
# ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC6eNtGpNGwstc....
输入上面命令,查看公钥。赋值添加到自已的gitee后台设置里面公钥设置里面。
示例
添加后,在终端(Terminal)中输入
ssh -T git@gitee.com
若返回
Welcome to Gitee.com, yourname!
则证明添加成功。
这操作下来完成后,在回去Android studio操作就不会上面的错误了。