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년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠