- Newest
- Most votes
- Most comments
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
I think it might be related to the account permission. I noticed the following when I tried to launch EC2 instance.
I am looking for an account which I have EC2 permission !! Thanks for all !!
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:
-
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.
-
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.
-
Security group settings: Ensure that your EC2 instance's security group allows inbound SSH traffic (port 22) from your IP address.
-
Instance state: Verify that your EC2 instance is in the "running" state.
To resolve this issue:
-
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
-
In PuTTY, make sure you're using the correct username for your EC2 instance in the "Auto-login username" field under Connection > Data.
-
Verify that you've selected the correct .ppk file in PuTTY under Connection > SSH > Auth > Credentials.
-
Double-check your EC2 instance's public DNS or IP address in PuTTY's Session configuration.
-
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
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
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
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
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 !!
The strange thing is I can create an EC2. I am not familiar with how AWS Service control policy works.
Relevant content
- asked 3 years ago
- asked a year ago
- AWS OFFICIALUpdated 3 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 9 months ago