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

질문됨 한 달 전114회 조회
1개 답변
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
전문가
답변함 한 달 전
profile pictureAWS
전문가
검토됨 한 달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠