問題:
有一段時間沒有用碼雲了,當輸入 git push -u origin master命令出現Please make sure you have the correct access rights and the repository exists.錯誤,
原因:
是git服務器沒有發現存儲本地的ssh密鑰。(git服務器已經存在我電腦的ssh秘鑰)
解決方案:
總思路:重新生成新的 ssh秘鑰,再把新的秘鑰添加到git服務器的ssh公鑰上。
解決問題步驟:
1. 刪除 .ssh 文件夾【C:\Users\(本地用戶名)\.ssh】 中的 known_hosts(手動刪除即可),
2. 在下載好的Git中的bin目錄下(一般是 C:\Program Files\Git\bin)打開bash.exe輸入命令ssh-keygen -t rsa -C "username" (注:username為你git上的用戶名),
3. 出現 Enter file in which to save the key (/Users/username/.ssh/id_rsa): //按回車
4. 返回/Users/your username/.ssh/id_rsa already exists.Overwrite (y/n)? //如果以前有存儲地址輸入y回車
5. Enter passphrase(empty for no passphrase): //如果以前沒有儲存地址就會出現這個,直接回車就好
6. 運行完成時 :username/.ssh/id_rsa.pub.(注:username為你git上的用戶名)中發現,已經新生成了id_rsa和id_rsa.pub兩個文件
7. 打開id_rsa.pub將全部的內容復制,到 git服務器的 “設置” > “安全設置” > “ssh公鑰”
8. 重新運行命令行就可以正常了。
祝:你們也和我一樣順利解決