在git push提示Please make sure you have the correct access rights and the repository exists.

时间:2024-03-14 08:27:14

在服务器上sudo git pull 的时候,报错 Please make sure you have the correct access rights and the repository exists.

解决步骤:
在gitbash中

  1. 输入 ssh-****** -t rsa -C “bneglect” //bneglect是你git操作的账号
    会显示 Generating public/private rsa key pair.
  2. Enter file in which to save the key (/home/liangwu/.ssh/id_rsa): //什么都不用输入,直接回车
    Enter passphrase (empty for no passphrase): //什么都不用输入,直接回车
    Enter same passphrase again: //什么都不用输入,直接回车
    显示 Your identification has been saved in /home/liangwu/.ssh/id_rsa.
    Your public key has been saved in /home/liangwu/.ssh/id_rsa.pub.
    The key fingerprint is:

SHA256:RbwKQOd9htV5zh9Qdl/EaWZQWqa5SJHeKgFk7nGHv0E bneglect
The key’s randomart image is:
±–[RSA 2048]----+
| … oo .oo.o+O=|
| .ooo +o.+.O==|
| …o+o=E.B= .|
| o o=*…+. |
| oS…+… …|
| … .o .|
| … |
| |
| |
±—[SHA256]-----+
在指定路径下生成了两个文件id_rsa.pub and id_rsa
我们需要把id_rsa.pub中的内容粘贴到服务器ssl证书管理处;
github参考输入公钥的位置如下图在git push提示Please make sure you have the correct access rights and the repository exists.

  1. 然后进入code.aliyun.com/profile目录下(或者找到设置->ssh公钥->增加ssh秘钥)
  2. (服务器上)**对所在目录 /home/bneglect/.ssh/

上面的方法没解决在看下面的
5. 如果修改了**对, 还是不好使,那么可以修改origin 地址, git remote -v 查看一下, 如果是ssh地址, 那么就登录github或者code阿里云复制https地址,
通过命令 git remote set-url origin https://code.aliyun.com/a/b.git 修改, 重新Git pull 试试
(举个栗子: 将url = [email protected]:manishnakar/polymer-demo.git ; 改成url = https://github.com/manishnakar/polymer-demo.git 即可)
6.猜测可能因为 (可能是因为git新账号的原因)(或者说可能是code阿里云上新成员)
7.需要重新选择下git上的ssh地址 因为默认配置的https地址


8.使用 cat .git/config 查看本地设置的仓库URL地址和github使用的链接地址是否一致.
ssh -T [email protected]检查公钥是否有问题

本文转载自https://www.cnblogs.com/bneglect/p/11253298.html
为查看方便略作补充。