AWS - Disconnected : No supported authentication methods available (server sent :publickey)

AvadData picture AvadData · Jul 5, 2014 · Viewed 162.6k times · Source

SSH to my AWS server just broke for both Putty and Filezilla. I'm making some effort for this post to be a comprehensive troubleshooting list, so if you share links to other stack overflow pages, I'll edit them into the question.

Disconnected : No supported authentication methods available (server sent :publickey)


The error is familiar from when I set up the connection almost a year ago. If you're setting up AWS SSH for the first time, these address the most common problems:

However, the only thing I could think that would impact a previously working system is:

  • Wrong IP: Restarting an AWS instance (or creating an image) is not guaranteed to keep the same IP address. This would obviously have to be updated in putty.

What other possibilities are there?

Solution to this one (per the accepted post below) is that for AWS EC2 all 3 of these need to have proper permissions (777 not ok for any of these). Here's one example that works:

/home/ec2-user/ - 700
/home/ec2-user/.ssh/ - 600
/home/ec2-user/.ssh/authorized_keys - 600

/var/log/secure will tell you which one is throwing an error, consult this video tutorial to get access if you're completely locked out: http://d2930476l2fsmh.cloudfront.net/LostKeypairRecoveryOfLinuxInstance.mp4

Answer

Tony Xu picture Tony Xu · Sep 18, 2017

I had the same problem, by accident mistake. I'll share it here, in case someone may have made the same mistake.

Basic steps, as others described.

  1. Download putty and puttygen, or the putty package and install it.
  2. Get the .pem file from your AWS EC2 instance.
  3. Use puttygen to convert the .pem file so that you'll have a private key --- mistake happened here. I chose "Conversions" tab from PuttyGen, and load my .pem file. After loading pem file, here DO NOT hit "Generate", instead directly "Save private key". That's the key you need. If you click Generate, you'll have a totally different pair of keys.
  4. In putty, use [email protected], and load the private key at SSH/Auth

Good luck!