"Server Refused our key" after launching instance from private EBS AMI

Viewed 51206

I have created my own EBS AMI, shared it with another AWS account, launched NEW instance based on this image with NEW key-pair and now when I am trying to connect to this new instance I am getting error: "Server Refused our key".

This is what I did (step by step):

  1. Configured new CentOS 6.3 server in my personal account (with my personal key-pair)
  2. Created EBS AMI image of that server
  3. Shared this image with my client's account
  4. Launched new instance in my clients account based on this shared image + new key-pair
  5. New launched instance doesnt want to take new key-pair. After some testing I figure that it accepts my personal key-pair instead.

How do I make new instance from my image to accept new key-pairs? I even tried removing ".ssh/authorized_keys" file in original image, launch new instance based on this image without public key and still no success.

Please advise how to create images that would not be attached to old key-pairs

12 Answers

I had this issue and it turned out I was typing ec2_user when it was meant to be ec2-user

In AWS Servers with different tools, the ssh key doesn't work

Error usually faced is

Server refused our key
No supported authentication methods available (server sent: publickey)

open the /etc/ssh/sshd_config file and add the below code

PubkeyAcceptedAlgorithms +ssh-rsa

and save the file and systemctl restart sshd to restart the sshd service Hopefully you key will work perfectly

In my case I was using Elastic Beanstalk and had not assigned my key pair to my configuration before launching it. To fix this:

  1. Go to your app in elastic beanstalk
  2. Navigate to configuration
  3. Scroll to security and select Edit
  4. Add your key pair to the instance
  5. Click save and try connecting again once the configuration has been applied

After following the steps given here and in other posts, I also had to update Putty to the current version. Then it all worked.

It could be only one reason to show Server Refused our key.

That is: server's Key Pair and Username combination is not correct, i have faced many times.

I am just updating my case too as an answer. I used to connect using hostname ec2-38-239-22-12.us-east-2.compute.amazonaws.com(Public IPv4 DNS) with a saved section in putty. Yesterday I stopped the instance and started facing this issue while trying to connect this morning, after booting instance(aws) this morning.

SOLUTION: Public IPv4 DNS record (ec2-38-239-22-12.us-east-2.compute.amazonaws.com)got changed after reboot. Logged to AWS Console and updated putty section with new record. this solved the issue !!

Related