unable to connect to the aws ec2 instance,Host key verification failed
Solution 1
You need to log in to your instance with the private key that you set it to use.
Depending on your instance, the user might vary
ssh -i [private key file] [user]@[host]
Where user could be one of the following in my experience (or possibly others)
- root
- ec2-user
- ec2user
- bitnami
- ubuntu
Solution 2
You may need to turn off StrictHostChecking by adding this option to ssh command line
-o StrictHostKeyChecking=no
Solution 3
As answered in more detail in your cross posted question on ServerFault: https://serverfault.com/questions/342228/unable-to-connect-to-the-aws-ec2-instance-host-key-verification-failed/342696#342696
Basically your ec2 elastic IP has previously been used with another server instance and your ssh client known hosts file does not match the new one for this IP. Remove offending line in known_host file. (More detail on Server Fault answer)
Jeevan Dongre
Geek under construction, Google fanboy, passionate learner, startup lover, business and tech savya, social media addict, biker, musician, extrovert, realistic, seminal, approachable.
Updated on June 27, 2022Comments
-
Jeevan Dongre almost 2 years
I had set up a ubuntu instance with rails package and also deployed my app, it is working fine.
But when i try to do SSH I its not allowing me for the remote login and throws errors like host key verification failed.
The problem seem to be persisting, kindly recommend the solution and I have attached a elastic IP to that and I am not able to see the public DNS, my instance is running in singapure region.
-
neodon over 11 yearsThis doesn't actually answer the question. It's about host key verification, not private key authentication. I am having this same issue on occasion with an EC2 instance, and it has to do with the host key verification failing before any authentication occurs. The second answer is correct.
-
Ishwor Khanal almost 4 yearsCant Imagine how tricky this solution is. It did trick to me . Thank you