Suddenly stopped connecting to EC2 with OpeSSH (through Mac)

0

It was all good until I tried to scp a folder from my local to EC2, then onwards it's not allowing me to get connected (using ssh with pem file) and says 'Permission denied (publickey)'. Not able to connect through AWS as well.

Enter image description here

I did reboot the EC2 instance through AWS. Created a new pem file and gave correct permissions. But no luck yet. Looking for help.

Thanks

asked 14 days ago98 views
1 Answer
0

Hello.

There may be some problem with the ssh process or ssh key, so it may be a good idea to connect to the OS using Systems Manager Session Manager and troubleshoot it.
I think you can use it if you meet the prerequisites listed in the document below.
https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-prerequisites.html

Also, you need to attach the IAM policy "AmazonSSMManagedInstanceCore" to the EC2 IAM role.
https://docs.aws.amazon.com/systems-manager/latest/userguide/getting-started-add-permissions-to-existing-profile.html

I think there are some troubleshooting things you can do on the SSH client side:
Try reducing the privileges of the client-side key pair as follows:

sudo chmod 400 ~/.ssh/key.pem

Also, try deleting the "known_hosts" file in the .ssh directory.

cd ~/.ssh && rm -Rf known_hosts

If you are using Windows as the client OS, the answers listed on stackoverflow below may be helpful.
https://stackoverflow.com/questions/64687271/how-to-avoid-permission-denied-publickey-ssh-key-windows

profile picture
EXPERT
answered 14 days ago
profile pictureAWS
EXPERT
reviewed 13 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