Question

I have created an Amazon EC2 instance. I have got the password file and it was lost. How to login now without the password ? Is there any way to create a new login ?

Was it helpful?

Solution

You can't once you deleted your private key file and if you don't have a copy of it then you have no way of logging in. You can try this assuming it's an EBS backed instance:

  1. Stop your EC2 instance
  2. Detach your root Volume (/dev/sda1) -- Assuming this is Volume A
  3. Spin up a new EC2 instance of the same type.
  4. Attach Volume A to that new instance as /dev/sdf
  5. ssh connect to his new instance.
  6. mkdir -p /mnt/xvdf
  7. mount /dev/xvdf /mnt/xvdf
  8. `cp ~/.ssh to /mnt/xvdf/home//.
  9. chmod 700 /mnt/xvdf/home/<username>
  10. chmod 600 /mnt/xvdf/home/<username>/authorized_keys
  11. Shutdown new instance
  12. Detach Volume A on new instance
  13. Reattach Volume A on /dev/sda1 on original instance.
  14. Start original instance.

You should be able to login now.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top