Unable to login through ssh. Permission denied public key

Hello I used to login from my terminal to my ec2 istance using this command

ssh -i mypemfile.pem ec2-user@my-ip

I have changed just the directory permission of my folder and and did this

sudo chmod -R 777 /home/ec2-user/

Now when I try to login it says

Permission denied (publickey)

Please help me how Can I go back. I am not able to login now

3

1 Answer

I'm not familiar is there a backdoor for amazon-ec2, but you should find a way to log-in into your server and change the permissions of the ~/.ssh directory and it's content as follow:

chmod go-w ~/
chmod 700 ~/.ssh
chmod 600 ~/.ssh/

See the topic "Permission denied (publickey)" within the section "Troubleshooting" of the article Public and Private Keys on the Ubuntu Documentation Wiki.

If the password authentication is not already disabled you can try to log-in by the following command (source):

ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no user@host
4

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like