
我想我的 ssh 配置搞亂了。
最近我無法再克隆本機儲存庫。 git 儲存庫似乎同時接受公鑰和密碼,但它沒有讓我選擇這兩個選項之一,而是嘗試使用一些錯誤的 RSA 金鑰進行連接,導致以下訊息:
Received disconnect from myRemoteComputer : Too many authentication failures for myUsername
fatal: Could not read from remote repository.
當我 ssh 到那台電腦時也會發生同樣的情況
$ssh -v myRemoteComputerIP
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/myUsername/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password
debug1: Offering RSA public key: myUsername@cvg04
Received disconnect from myRemoteComputerIP: Too many authentication failures for myUsername
所以出了問題,因為最近兩個指令都正常運作。我基本上需要告訴ssh
並git
使用使用者名稱和密碼,而不是隨機選擇錯誤的「RSA 金鑰」。有誰知道如何修復這個?
我ssh-add
最近也按照一些論壇建議執行了一些命令,但也許這是問題的一部分...
答案1
檢查你的~/.ssh/config
。如果你想使用密碼驗證,你可以像這樣設定:
Host myRemoteComputerIP
PubkeyAuthentication no
它永遠不會嘗試針對該主機進行公鑰身份驗證。
當我必須使用 rsa 金鑰和另一個使用者名稱/密碼身份驗證連接兩個不同的使用者名稱時怎麼樣?
您可以在以下位置使用別名ssh_config
:
Host alias1
Hostname myRemoteComputerIP
PubkeyAuthentication no
User user1
Host alias2
Hostname myRemoteComputerIP
# PubkeyAuthentication yes # is default
User user2
然後使用ssh alias1
和連接ssh alias2
。
答案2
使用 https 克隆,它總是會要求輸入密碼。例子:
git clone https://github.com/my_company/myrepo.git