SSH_MSG_DISCONNECT: 2 Too many authentication failures

0

I create a new instance, the secret pem is right, but i can not access the instance in my ssh client. The error is "SSH_MSG_DISCONNECT: 2 Too many authentication failures", so what's the problem? can someone help me? thanks!

已提問 2 年前檢視次數 4346 次
1 個回答
0

Hey there, 

You mention that you cannot SSH into your instance due to the error “2 Too many authentication failures”. The authentication failures can occur due to the etc/ssh/sshd_config, which is where the MaxAuthTries (maximum Authentication tries) setting to a # (bastion host) is and the value is a small number. The default value for the MaxAuthTries is 6 . This happens when multiple keys are configured within the SSH-Agent and the client uses all keys to connect to the server. With all the keys failing authentication the server will then close the connection and produce the mentioned error.

To resolve the issue remove keys from the SSH-agent:

ssh-add -L

Shows all keys on keychain

Ssh-add-D

Deletes all the keys from the keychain

Ssh -A user@<bastion-IP-address>

To connect to your instance

Alternate solutions: ssh key forwarding manually

ssh-add myPrivateKey.pem

ssh-add –L

ssh –A user@<bastion-IP-address>

Alternate solutions:

  • Increase the MaxAuthTries on the server
  • Edit the ~/.ssh/config (on the client) and add IdentitiesOnly blocks so that a connection to a specific host only tries the associated key
  • Force non-key authentication, e.g.: ssh -o PubkeyAuthentication=no romain@hostname.com

References :

[1] https://cloudmaniac.net/how-to-fix-ssh-too-many-authentication-failures/

[2] https://stackoverflow.com/questions/31051504/unable-to-connect-from-ec2-server

Antonio
已回答 2 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南