By using AWS re:Post, you agree to the AWS re:Post Terms of Use

EC2 key-pair question

0

I did the following: Enter image description here Then I have the downloaded demo-key.ppk I used putty to login EC2 by private key, but I got the following: Enter image description here

What did I miss ?

thanks !!

asked 21 days ago80 views
10 Answers
2

Hello.

Try the troubleshooting methods in the documentation below one by one.
https://repost.aws/knowledge-center/ec2-server-refused-our-key

Also, in rare cases, an older version of Putty may cause such an error, so please make sure you are using the latest version.
https://stackoverflow.com/a/77125255

profile picture
EXPERT
answered 21 days ago
profile picture
EXPERT
reviewed 21 days ago
1
Accepted Answer

I think it might be related to the account permission. I noticed the following when I tried to launch EC2 instance. Enter image description here

I am looking for an account which I have EC2 permission !! Thanks for all !!

answered 20 days ago
profile picture
EXPERT
reviewed 20 days ago
1

Based on the information provided, it appears you've created an EC2 key pair and downloaded the private key file with a .ppk extension. However, you're encountering an issue when trying to log in to your EC2 instance using PuTTY. There are a few potential reasons for this error:

  1. Key format mismatch: The .ppk file format is specific to PuTTY, but Amazon EC2 typically provides the private key in .pem format. You may need to convert the .pem file to .ppk format using PuTTYgen.

  2. Incorrect username: The error message suggests you might be using the wrong username to connect. For Amazon Linux instances, the default username is typically "ec2-user". For Ubuntu instances, it's usually "ubuntu". Make sure you're using the correct username for your specific EC2 instance's operating system.

  3. Security group settings: Ensure that your EC2 instance's security group allows inbound SSH traffic (port 22) from your IP address.

  4. Instance state: Verify that your EC2 instance is in the "running" state.

To resolve this issue:

  1. If you have the original .pem file, use PuTTYgen to convert it to .ppk format:

    • Open PuTTYgen
    • Click "Load" and select your .pem file
    • Click "Save private key" to create a .ppk file
  2. In PuTTY, make sure you're using the correct username for your EC2 instance in the "Auto-login username" field under Connection > Data.

  3. Verify that you've selected the correct .ppk file in PuTTY under Connection > SSH > Auth > Credentials.

  4. Double-check your EC2 instance's public DNS or IP address in PuTTY's Session configuration.

  5. Ensure your EC2 instance's security group allows SSH access from your IP address.

If you've followed these steps and are still encountering issues, you may want to try alternative methods of accessing your instance, such as using the EC2 Instance Connect feature through the AWS Management Console or the AWS CLI.
Sources
Create a key pair for your Amazon EC2 instance - Amazon Elastic Compute Cloud
Community | Recovering Access: A Guide for Lost EC2 Key Pair in Linux
Amazon EC2 key pairs and Amazon EC2 instances - Amazon Elastic Compute Cloud

profile picture
answered 21 days ago
profile picture
EXPERT
reviewed 21 days ago
1

possible to be related to permission ?

If you can start with the EC2 key pair set, the private key should be set in "authorized_keys" for the default user of the OS, so I don't think IAM permissions are relevant.
I recommend that you connect to EC2 using Systems Manager Session Manager or EC2 Instance Connect and check the sshd logs.
https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-getting-started.html

If your PC uses MacOS or Linux, please execute the following command to change the permissions of the key pair.
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/create-key-pairs.html

chmod 400 key-pair-name.pem

For Windows, try changing the permissions from security as shown in the answer on the following site.
https://superuser.com/questions/1296024/windows-ssh-permissions-for-private-key-are-too-open

profile picture
EXPERT
answered 20 days ago
profile picture
EXPERT
reviewed 20 days ago
1

I don't think the error shown in the image has anything to do with the EC2 key pair.
The error is occurring because the IAM user you are using does not have permission to view AWS free tier information.
It has nothing to do with key pair settings.
https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsfreetier.html

If you have determined that there is a problem with the IAM policy, why not try setting "AmazonEC2FullAccess" or "AdministratorAccess" for the IAM user and starting EC2?
https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AmazonEC2FullAccess.html
https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AdministratorAccess.html

profile picture
EXPERT
answered 20 days ago
profile picture
EXPERT
reviewed 20 days ago
0

When you created the key pair did you then proceed to create the ec2 and select the key pair?

You can’t create the key pair after creating the ec2

profile picture
EXPERT
answered 21 days ago
0

Yes, I created a key-pair first, then created an EC2 and attaching key-pair to EC2. I tried a couple of times, got the same error. possible to be related to permission ? seems not, as I can create an EC2. but not sure. thanks !!

answered 21 days ago
0

As I do not have privilege to set it.

thanks so much !!

answered 20 days ago
0

The strange thing is I can create an EC2. I am not familiar with how AWS Service control policy works.

answered 20 days ago
0

I found it the issue. It was caused by the putty of version.

answered 19 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions