2

I am trying to connect to an EC2 instance with the key. But I get an error saying

No supported authentication methods available (the server sent: public key")

In the command window I get:

Using username "ec2-user"Server refused our key

. Please help me

askedApr 17, 2020 at 16:19
karishma seetharaman's user avatar
2
  • Help is here:docs.aws.amazon.com/AWSEC2/latest/UserGuide/…CommentedApr 17, 2020 at 16:34
  • Server refused our key means that the keypair you provided does not match one that is installed on the server. For example, if you connect withssh -i keypair.pem ec2-user@IP-ADDRESS, thenkeypair.pem must match a keypair installed on the instance (eg it was selected when the instance was launched).CommentedApr 18, 2020 at 0:23

2 Answers2

4

I will try to help! Suppose you are trying to connect using the PuTTY SSH client on your local machine. (Connecting with an FTP client like WinSCP is very similar).

Short answer: You need to let PuTTY know your ec2user IP address and associate the private key of the EC2 instance with the PuTTY session. On the AWS side you need to create a security group that allows inbound access from your IP address to your EC2 instance for SSH on port 22.

__

Long answer 😊:

  1. Go to your EC2 page and click [CONNECT][enter image description here]1

  1. Copy the ec2User IP address to PuTTY.enter image description here

  1. When you created the EC2 instance, you were prompted to download the public/private key pair. You need that private key. If you don’t have that file, things are more complicated. (SeeChange key pair for ec2 instance).But hopefully, you can find the private PuTTY Private Key file downloaded on your local machine:enter image description here

  1. Save the session. PuTTY should be all set up now.

  2. Now on the AWS side, you need to make a new security Group:enter image description here


  1. Create the group and ADD an Inbound Rule:enter image description here

  1. Go back to EC2 and add security group to EC2.enter image description here

  1. In the dialog that pops up, check the security group that you just created for PuTTY remote access and click [Assign Security Groups]

Now give it a try!

I hope this works for you like it does for me.

ONE FINAL TIP: Make sure that you associate an Elastic IP address to the instance. Otherwise, this connection might stop working when someday you reboot your EC2. The elastic IP pins it down.

answeredApr 19, 2020 at 16:23
IV.'s user avatar
Sign up to request clarification or add additional context in comments.

1 Comment

Fantastic! Thanks for letting me know. Perhaps you'd kindly consider marking it as the solution? Thank you.
1

Verify that you are connecting with the appropriate user name for your AMI. Type the user name in User name in the PuTTY Configuration window.

The appropriate user names are as follows:

For Amazon Linux 2 or the Amazon Linux AMI, the user name is ec2-user.

For a CentOS AMI, the user name is centos.

For a Debian AMI, the user name is admin or root.

For a Fedora AMI, the user name is ec2-user or fedora.

For a RHEL AMI, the user name is ec2-user or root.

For a SUSE AMI, the user name is ec2-user or root.

For an Ubuntu AMI, the user name is ubuntu.

Otherwise, if ec2-user and root don't work, check with the AMI provider.

You should also verify that your private key (.pem) file has been correctly converted to the format recognized by PuTTY (.ppk).

answeredApr 18, 2020 at 2:11
Ali's user avatar

1 Comment

I created parse server in this instance, but I am not sure of the username to be used, but I tried everything, ec-2user , root, ubuntu etc.

Your Answer

Sign up orlog in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

By clicking “Post Your Answer”, you agree to ourterms of service and acknowledge you have read ourprivacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.