ssh auth not working for accessing instance or sftp

0

Hi there,

I shared my default key with someone else so I went ahead and deleted it for security reasons.

I then created a new ssh keypair on my mac (ssh keygen) and uploaded the public key to /home/bitnami/.ssh/authorized_keys and tried to ssh in. That is the process isn't it? I can't seem to login or connect using the private key that matches the public key on the server, though it should?

Also I tried using the dropdown in the SSH key section of the management page but again that key doesn't work either.

Thank you

asked a year ago242 views
1 Answer
0
Accepted Answer

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.

profile picture
answered a year ago
  • Thank you, it turns out there was a space/new line after ssh-rsa which was causing the issue!

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