Posted at

[Too many authentication failures for ec2-user]で、EC2にSSH接続出来無い場合の解決方法

More than 3 years have passed since last update.

CIS Amazon Linuxを使う機会があったので、早速いつも通りにSSHしようとしたら・・・

ssh -i ~/.ssh/aws.pem ec2-user@xxx.xxx.xxx.xxx                                                                       

The authenticity of host 'xxx.xxx.xxx.xxx (xxx.xxx.xxx.xxx)' can't be established.

(省略)

If you are not an authorized user of this system or do not consent to continued
monitoring, disconnect at this time.
Received disconnect from xxx.xxx.xxx.xxx: 2: Too many authentication failures for ec2-user
Disconnected from xxx.xxx.xxx.xxx

ってなってしまった。

このような場合になった時は、

ssh -o IdentitiesOnly=yes -i ~/.ssh/aws.pem  -l ec2-user xxx.xxx.xxx.xxx                                             

This is a private computer system which is restricted to authorized individuals.

Actual or attempted unauthorized use of this computer system will result in
criminal and/or civil prosecution.

We reserve the right to view, monitor and record activity on the system without
notice or permission. Any information obtained by monitoring, reviewing or
recording is subject to review by law enforcement organizations in connection
with the investigation or prosecution of possible criminal activity on this system.

If you are not an authorized user of this system or do not consent to continued
monitoring, disconnect at this time.

__| __|_ )
_| ( / Amazon Linux AMI
___|\___|___|

https://aws.amazon.com/amazon-linux-ami/2015.03-release-notes/
25 package(s) needed for security, out of 102 available
Run "sudo yum update" to apply all updates.
Amazon Linux version 2015.09 is available.
[ec2-user@ip-10-0-0-170 ~]$

で接続できる。

ポイントは-o IdentitiesOnly=yes -l ec2-user xxx.xxx.xxx.xxxってなったところ。