This is a comment/quetion
I followed all the steps in this lecture and something strange happened when I tried to login with the newly created key that I downloaded from the S3 bucket:
when I tried to login with ec2-user, I got a
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
error. When I tried with "root" as the user, it logged in successfully. I then tried to login with the original key that I associated when setting up the instance and it worked with ec2-user.
Any ideas why this happened?
From your description it sounds like you added the public key under the root user’s authorized_keys instead of ec2-user’s. If you add the second public key to the location in ec2-users home folder (should be /home/ec2-user/.ssh/authorized_keys) it should work fine
makes sense. thank you