我在 github 上使用 SSH 密鑰有一段時間了,現在我已經切換到一個新帳戶,Git 仍在嘗試使用我的舊 SSH 密鑰。這是我嘗試推送時得到的結果:
remote: Permission to ***REPO*** denied to ***OLD USERNAME***
fatal: unable to access ***REPO***: The requested URL returned error: 403
我的 .gitconfig 檔案具有正確的電子郵件和名稱。
我的 ~\.ssh\config 檔案內容如下:
Host github.com
IdentityFile ~/.ssh/id_ed25519 ***The correct key***
IdentitiesOnly yes
我洗掉了舊的密鑰檔案。
當我運行 ssh-add -l 時,列出的唯一鍵是正確的。
我還卸載并重新安裝了 Git。
有沒有人有任何見解?某處或某處是否有 ssh-agent 的全域組態檔?我不知道該怎么做,我能想到的唯一下一步就是重新安裝 Windows。
uj5u.com熱心網友回復:
首先,確保您使用的是 SSH URL:
ssh://[email protected]/<newUser>/myproject
# or
[email protected]:<newUser>/myproject
所以:
cd /path/to/local/repo
git remote -v
如果您要使用 HTTPS URL,那么舊的用戶名/密碼可能會被憑證助手快取(檢查 的值git config --global credential.helper)
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/441098.html
