Check that you have existing ssh key working and we can log in to the machine using it. You can also directly login via a new function in AWS console.
Generate a new SSH key via Amazon Web Console
Get the public key from it. Using the command below
ssh-keygen -y -f ~/Downloads/second.pem
If working on Windows system using this https://www.puttygen.com/convert-pem-to-ppk
Login to the machine and edit the file.
Add the new public key and check that you are able to login with the new key
Change permission of new key to 400 and try to login
If login is successful delete the old key from authorized keys file