在服務器上sudo git pull 的時候,報錯 Please make sure you have the correct access rights and the repository exists.
解決步驟:
1. 輸入 ssh-keygen -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]-----+
3. 然后進入code.aliyun.com/profile目錄下(或者找到設置->ssh公鑰->增加ssh秘鑰)
4. (服務器上)密鑰對所在目錄 /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 = git@github.com: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 git@github.com檢查公鑰是否有問題