When I use SSH to connect to an Amazon EC2 Linux instance, 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're not connecting with the appropriate user name for your AMI when you negotiate an SSH session with an EC2 instance.
  • You're using the wrong private key when you negotiate an SSH session with an EC2 instance.

To resolve this issue, follow these steps:

If you're 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 using SSH.
  4. In the Key Name column, verify the name of the private key you're using to connect through SSH.

If you're 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.
  • Verify that your private key (.pem) file is converted to the format recognized by PuTTY (.ppk). For more information, see Converting your Private Key Using PuTTYgen.

If you're 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.


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

Updated: 2018-04-10