解釋
這個報錯通常是因為多個ssh key 驗證,key太多了導致服務器拒絕接受認證請求。
可以通過 -v
參數,輸出詳細的過程。你會發現你提供的認證key,服務器拒絕鏈接,並提示異常:“Too many authentication failures for [user]”。
解決辦法
ssh-add -D
詳細解釋
This is usually caused by inadvertently offering multiple ssh keys to the server. The server will reject any key after too many keys have been offered.
You can see this for yourself by adding the -v
flag to your ssh
command to get verbose output. You will see that a bunch of keys are offered, until the server rejects the connection saying: "Too many authentication failures for [user]". Without verbose mode, you will only see the ambiguous message "Connection reset by peer".
To prevent irrelevant keys from being offered, you have to explicitly specify this in every host entry in the ~/.ssh/config
file by adding IdentitiesOnly
like so:
Host www.somehost.com
IdentityFile ~/.ssh/key_for_somehost_rsa
IdentitiesOnly yes
Port 22
If you use the ssh-agent, it helps to run ssh-add -D
to clear the identities.
If you are not using any ssh hosts configuration, you have to explicitly specify the correct key in the ssh command like so:
ssh -i some_id_rsa -o 'IdentitiesOnly yes' them@there:/path/
Note: the 'IdentitiesOnly yes' parameter needed to be between quotes.
or
ssh -i some_id_rsa -o IdentitiesOnly=yes them@there:/path/