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
- Help is here:docs.aws.amazon.com/AWSEC2/latest/UserGuide/…jarmod– jarmod2020-04-17 16:34:37 +00:00CommentedApr 17, 2020 at 16:34
Server refused our keymeans 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.pemmust match a keypair installed on the instance (eg it was selected when the instance was launched).John Rotenstein– John Rotenstein2020-04-18 00:23:01 +00:00CommentedApr 18, 2020 at 0:23
2 Answers2
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 😊:
- Go to your EC2 page and click [CONNECT][
]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:

Save the session. PuTTY should be all set up now.
- 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.
1 Comment
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).
1 Comment
Explore related questions
See similar questions with these tags.





