0

I have been using this since last 5 month but today I have updated .ssh/authorised_keys (change my directory) and also was working fine. But when giving access to another machine (by update .ssh/authorised_keys (friend machine key )) then it is not working and now I am also unable to log in.

  $ ssh -i "dev.pem" [email protected]
    [email protected]: Permission denied (publickey).

Can anyone give me a solution?

4
  • Where did you store the private key file? You need to pass a full file path to the -i directive unless you are in the same directory as the private key file.
    – Thomas Ward
    Aug 19, 2018 at 16:50
  • yeah..it is in same directory Aug 19, 2018 at 16:51
  • i have updated .ssh/authorised_keys but any other way to login and change ,ssh/authorised_key Aug 19, 2018 at 16:55
  • It's .ssh/authorized_keys not .ssh/authorised_keys (the British spelling is not the proper spelling unfortunately, to my knowledge)
    – Thomas Ward
    Aug 19, 2018 at 17:38

2 Answers 2

0

If you have changed your SSH setup including having the wrong file permissions on .ssh/authorized_keys, you will need to do a recovery process if you cannot login:

Before making any changes, create a snapshot of your system (or create an AMI) just in case you make your problem worse.

  1. Start a new EC2 instance.
  2. Stop the broken EC2 instance.
  3. Detach the root (boot) volume from the broken EC2 instance.
  4. Attach the volume to the new EC2 instance as additional disk.
  5. Mount the file root file system to a temporary directory.
  6. Troubleshoot and fix the problem. In your case set the correct file permissions.
  7. Detach the volume from the new EC2 instance.
  8. Attach the volume to the broken EC2 instance.
  9. Start the broken EC2 instance.
  10. Verify everything works. Go back to Step 2 to repeat.
  11. Terminate the new EC2 instance when no longer needed.
0

Be sure that /etc/ssh/sshd_config is factory default. I probably changed, activated "#PubkeyAuthentication yes"; that caused: Permission denied (publickey)

1
  • HDK Bouma... This should be a comment, please. I understand that you may not have the privilege to comment. Sep 28, 2018 at 12:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .