Sunday, August 25, 2013

Amazon Authentication failed. How to recovery

The problem with EC2 instance when I try to connect via SSH. Authentication failed.Permission denied
  1. Stop the running EC2 instance
  2. Detach its /dev/sda1 volume (let's call it volume A)
  3. Start new t1.micro EC2 instance, using a new key pair
  4. Attach volume A to the new micro instance, as /dev/xvdf
  5. SSH to the new micro instance and $ sudo mkdir /mnt/tmp
  6. $ mount /dev/xvdf  /mnt/tmp
  7. $ cd /mnt/tmp and copy all needed data
  8. You can try to change  keypair for you your old instance on a new
     Copy ~/.ssh/authorized_keys to /mnt/tmp/home/ubuntu/.ssh/authorized_keys
  9. Logout
  10. Terminate micro instance
  11. Detach volume A from it
  12. Attach volume A back to the main instance as /dev/sda1
  13. Start the main instance
  14. Login as before, using your new .pem file