- Newest
- Most votes
- Most comments
Here are a few things you can try to troubleshoot and resolve the issue:
Check the permissions on the authorized_keys file: The authorized_keys file should have the permissions of 600 (-rw-------). You can check the permissions by running ls -la on the .ssh directory, and if the permissions are not correct, you can change them using the command chmod 600 authorized_keys.
Check the format of the public key: Ensure that the public key you uploaded to the server is in the correct format. The key should start with "ssh-rsa" and should not contain any extra white spaces or line breaks.
Check the user you are trying to connect as: Make sure that you are trying to connect as the correct user on the EC2 instance. By default, the user is "ec2-user" for Amazon Linux and "ubuntu" for Ubuntu.
Check the security group: Make sure that the security group associated with the EC2 instance has an inbound rule allowing incoming traffic on port 22 (SSH) from your IP address.
Check the EC2 instance's state: Make sure that the EC2 instance is in a running state and that the status checks are passed.
Create and use new key pair on the EC2 management console: If none of the above steps resolve the issue, you can try creating a new key pair on the EC2 management console and use it to connect to the instance.
If none of the above steps resolve the issue, it may be helpful to review the EC2's system and instance logs to see if there are any error messages or issues that are preventing the connection.
Relevant content
- asked 5 years ago
- asked 4 months ago
- Accepted Answerasked 17 days ago
- asked 3 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 20 days ago
- AWS OFFICIALUpdated a year ago
Thank you, it turns out there was a space/new line after ssh-rsa which was causing the issue!