4
votes

I was working on an amazon ec2 instance for almost a week now.. I installed LAMP on my ubuntu instance then suddenly yesterday, when I try to connect via SSH on putty it gives me an error "Server refused our key" and "No supported authentication methods available (server sent: public key)

enter image description here

I am not sure what is causing this error since i did not change any settings on the aws console and on the instance itself. I was able to ssh before on the server. before I start setting up the server, I assigned an elastic IP to the instance.

4
did you get solved this problem?CLIFFORD P Y
I used bitnami 's WordPress AMI on AWS and I was facing the same issue. The was management console guessed the username for putty as admin for Debian which was incorrect. After searching the AMI is found the correct name was bitnami. Once I used the same as the username I n putty I was able to connect.Anshumaan Bakshi

4 Answers

2
votes

I am in the process of setting up ubuntu-Wordpress on aws EC2 using a Bitnami AMI. I added SSH-based security in the last installation sted and thus downloaded a .pem private key. Trying to use putty to create a SSH-tunnel I ran into the wellknown putty login problems, both regarding username and private key. I solved them in the following way: 1) username should be "bitnami" (ec2-user is not working) 2) Using puttykey to convert the public SSH-key from .pem to .ppk (as putty demands private key in ppk format) I had to use SSH-1 (RSA) instead of the default parameter. By doing so putty gave perfect connection to the private IP of my EC2 instance. Hope this helps!

0
votes

The public key that is being sent by Putty to the instance is being rejected. Even though you may not have changed anything something has changed. Things to check include making sure you are logging in as the correct user, Putty is able to read the public key file, and that you are trying to log in to the correct EC2 instance. If your instance did not have an Elastic IP and your instance has been stopped and started, the instance's public IP would have changed and you are now connecting to a different instance. Confirm everything in the SSH connection is correct.

0
votes

What works for me is that:

  • Stopped the ec2 instance
  • detach the volume
  • attach the volume with the old instance using the same key and was able to SSH
  • mount the volume in some temp folder
  • checked the file in the directory mount_point/home/ec2-user/.ssh/authorized_keys
    Ideally, this file needs to have our key information but for me this file was empty
  • copied the old instance authorized_keys file to the newly mounted volume
  • unmount the device
  • reattach to the original ec2 instance
  • start it and let it pass the health checks

This time it works for me. But I don't know why it doesn't have my key file information at first when the instance was launched. Check this link too https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/TroubleshootingInstancesConnecting.html#TroubleshootingInstancesConnectingMindTerm

0
votes

I tried witch ec2-user for the longest time, until realizing that this is only valid for Amazon Linux. For the Ubuntu Server 18.04 AMI, the user is ubuntu (at least at the time of writing).

enter image description here