簡體   English   中英

從 Bitbucket Git Repos 拉取時,Pageant 中的多個 SSH 鍵會導致失敗

[英]Multiple SSH keys in Pageant cause failures when pulling from Bitbucket Git Repos

我遇到的問題與此處描述的問題非常相似。 然而,不同之處在於我正在嘗試使用 Pageant 作為我的代理而不是 OpenSSH。 我發現當我在 Pageant 中加載了兩個不同的 Bitbucket 帳戶的 SSH 密鑰時,兩個存儲庫之一將始終運行 Git 命令,而另一個將失敗。 工作的 repo 取決於哪個 SSH 鍵在 Pageant 鍵列表中排在第一位。

“失敗”是指從 Git 命令返回以下錯誤:

git -c diff.mnemonicprefix=false -c core.quotepath=false --no-optional-locks fetch origin
Forbidden
fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

Completed with errors, see above.

我不知道這是 PuTTY/Pageant、SourceTree 還是 Bitbucket 問題。 我懷疑這是一個 Bitbucket 問題,因為我發現如果我從 Bitbucket 帳戶 A 中刪除密鑰 A,然后嘗試在存儲庫 B 上獲取,那么即使密鑰 A 和 B 都加載到 Pageant 中,命令也會成功。 換句話說,當密鑰未附加到任何 Bitbucket 帳戶時,Bitbucket 似乎沒有問題。

有沒有人讓 Pageant 使用同時為多個 Bitbucket 回購加載的密鑰?

我在這個對我有用的博客中找到了答案: craigtp.co.uk

對於您的第一個帳戶和密鑰,只需正常設置即可。

對於第二個帳戶,

  1. 啟動膩子
  2. Host Name中,輸入真實地址(例如 github.com)
  3. Go 到Connection > SSH > Auth並在Private Key File 下加載您的第二個私鑰以進行身份驗證
  4. Go 到Session ,然后在Saved Sessions中鍵入一個沒有空格的名稱,然后單擊 Save。 那將是你的別名。

例如,如果您將別名命名為github-second ,那么當您為第二個帳戶克隆存儲庫時,請使用別名。 例如

git clone git@github-second:blah/blahblah.git

對於您所說的,您似乎已經在某個時間點克隆了存儲庫。 在這種情況下,只需更新遙控器即可。

檢查您當前的遙控器。 它應該看起來像這樣,

git remote -v
origin  git@github.com:blah/blahblah.git 

然后,使用以下命令更新遙控器:

git remote set-url origin git@github-second:blah/blahblah.git

那應該工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM