When I attempt to connect to a Linux Amazon EC2 instance by using SSH, I receive an error similar to one of the following:

Using username "root".
Authentication with public key "imported-openssh-key"
Please login as the user "ec2-user" rather than the user "root".

- or -

Using username "ec2-user".
Server refused our key

Or, when using the PuTTY client, I receive an error similar to the following:

PuTTY Fatal Error:
Disconnected: No supported authentication methods available (server sent: publickey)
OK

This error can occur under the following circumstances:

  • You are not connecting with the appropriate username for your AMI when you negotiate an SSH session with an EC2 instance.
  • You use the wrong private key when you negotiate an SSH session with an EC2 instance.

To resolve this problem, follow these steps:

If you are connecting with an appropriate user name, verify that you are using the correct private key by following these steps:

  1. Sign in to your AWS account and open the Amazon EC2 console.
  2. In the navigation pane, choose Instances.
  3. Find the EC2 instance you want to connect to via SSH.
  4. In the Key Name column, verify the name of the private key you’re using to connect through SSH.
  • If you are using PuTTY, verify that the SSH private key matches the private key you see in the Key Name column for your EC2 instance in the console.
  • If you are using OS X or Linux, check the directory and file name you specify after the -i flag to make sure it’s the correct path to your private key. The private key should match the key you see in the Key Name column for your EC2 instance in the console.

For more information on troubleshooting connectivity issues, see Troubleshooting Connecting to your Instance, or create a case with AWS Support.

EC2, connectivity issue, SSH, PuTTY, private key, login


Did this page help you? Yes | No

Back to the AWS Support Knowledge Center

Need help? Visit the AWS Support Center

Published: 2016-05-24