Git push-Permission denied,TortoiseGit可正常同步,Git Bash失敗

背景:公司內部服務器個人git倉庫,同時可通過Samba訪問。

問題現象:由於之前一直在window下用小烏龜界面操作,最近開始逐漸嘗試在Ubuntu上開發,所以開始試着使用git bash來維護代碼,簡單的git status,git diff,git add以及git commit操作一切正常,但是在git pull以及git push時遇到了問題;

提示信息爲:

Permission denied(publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.

首先這個倉庫是一定存在的了,那麼應當是認證出了問題;

git config —global --list

用戶名以及郵箱無誤,那應當是密鑰的問題的;

由於小烏龜可以正常推送,所以查詢小烏龜的密鑰後,發現我的這個小烏龜密鑰存放地址爲:

c:/Users/{$your id}/Documents/.ssh/

而git bash的密鑰存放地址爲

c:/Users/{$your id}/.ssh/

將小烏龜的密鑰複製過來,問題解決。

當然從新生成一份密鑰然後全部替換掉也可以:

ssh-keygen -t rsa -C "[email protected]"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/{$}/.ssh/id_rsa)

或許我應該將小烏龜的密鑰地址更改到與bash中一致?
避免同一個用戶存放不同的認證密鑰?

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章