No supported authentication method available when I try to connect to ec2. How to connect to the AWS instance?

Viewed 2443

I create ec2-instance on the AWS server:

enter image description here

Now I try to connect to the server with putty.

  • First of all, I downloaded the PPK for instance:

enter image description here

  • In the next I created a connection with putty:

enter image description here

enter image description here

  • After I launch connection and set the username as ec2-user:

enter image description here

  • in the result I got the error:

enter image description here


How to correctly connect to the ec2 instance with PPK?

2 Answers

What I understand from the question is that you did launch an EC2 instance successfully and afterwards you generated a new SSH key pair which does not have any connection to the already created EC2 instance.

What you should have done is to create a new key when the instance was launched: enter image description here

OR select an existing key:

enter image description here

Now, the easiest way to solve this problem is to terminate the EC2 instance and recreate it with your existing key pair. You should be able to chose wlifter-ppk from the dropdown.

If, for some reason, you don't want to do this or it is not possible to terminate and relaunch the instance, there are several ways to rescue the instance and attach an existing SSH key.

I. Manually rescue the instance:

  1. From Putty convert you .ppk to RSA public key.
  2. Use EC2 Instance Connect or Session Manager to connect to your instance.
  3. Locate the .ssh/authorized_keys file. For Amazon Linux instances this can be found in /home/ec2-user/.ssh folder.
  4. Open authorized_keys, append the new RSA public key and save the file.
  5. Connect to the instance using Putty.

II. Use EC2Rescue tool https://aws.amazon.com/premiumsupport/knowledge-center/ec2-instance-boot-issues/

I assume you have local Windows and you'd like to connect to your EC2 AWS linux VM.

  1. Use PuTTYgen to generate SSH-2 RSA key, 2048 bits.
  2. Save keys into file, ie. myaws1.pub and myaws1.
  3. In AWS dashboard, find your live instance, open up shell. It'll open up in the browser.
  4. You will be logged in most likely as ec2-user
  5. vi .ssh/authorized_keys
  6. On your Windows, open up myaws1.pub file. take the relevant part and make it one line. Yes, it's broken up into multiple lines. Now press CTRL-C. And over in the browser where you Linux shell, press ESC-I (for insert), now CTRL-V (paste). Save and exit vi.
  7. Back to Amazon Dashboard, in Network Security -> Security Groups, create SSH inbound rule with source 0.0.0.0/0
  8. Now, when connecting to your instance from Putty use "Auth" in options.

This is what your new line in auth file should look like. I shortened it

ssh-rsa AAAAB3......... aws1

Related