Enterprise Cloud Consultancy in The UK and Europe

Lost Key for EBS Instance

If you lose the private key for an EBS-backed instance, you can regain access to your instance. You must stop the instance, detach its root volume and attach it to another instance as a data volume, modify the authorized_keys file with a new public key, move the volume back to the original instance, and restart the instance.

Steps for connecting to an EBS-backed instance with a different key pair

  • Step 1: Create a new key pair
  • Step 2: Get information about the original instance and its root volume
  • Step 3: Stop the original instance
  • Step 4: Launch a temporary instance
  • Step 5: Detach the root volume from the original instance and attach it to the temporary instance
  • Step 6: Add the new public key to authorized_keys on the original volume mounted to the temporary instance
  • Step 7: Unmount and detach the original volume from the temporary instance, and reattach it to the original instance
  • Step 8: Connect to the original instance using the new key pair
  • Step 9: Terminate the temporary instance