Bird
0
0

If you lose the private key file for an EC2 instance's key pair, which method is the recommended way to regain SSH access without terminating the instance?

medium📝 Debug Q7 of 15
AWS - EC2 Fundamentals
If you lose the private key file for an EC2 instance's key pair, which method is the recommended way to regain SSH access without terminating the instance?
ALaunch a new EC2 instance with a new key pair and migrate your data
BRequest AWS support to recover the lost private key file
CCreate a new key pair, stop the instance, detach the root volume, attach it to another instance, modify the authorized_keys file, then reattach and start the instance
DUse the AWS Management Console to download the private key again
Step-by-Step Solution
Solution:
  1. Step 1: Understand AWS key pair limitations

    A private key cannot be recovered or downloaded again after creation.
  2. Step 2: Regain access by modifying authorized_keys

    The recommended approach is to create a new key pair, then modify the instance's root volume's authorized_keys file by mounting it on another instance.
  3. Step 3: Avoid data loss

    This method avoids terminating or recreating the instance, preserving data and configuration.
  4. Final Answer:

    Create a new key pair, stop the instance, detach the root volume, attach it to another instance, modify the authorized_keys file, then reattach and start the instance -> Option C
  5. Quick Check:

    Private keys cannot be re-downloaded; modify authorized_keys instead [OK]
Quick Trick: Modify authorized_keys via volume attachment to regain access [OK]
Common Mistakes:
  • Expecting AWS to provide lost private keys
  • Terminating instance unnecessarily
  • Trying to download private key again from console

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More AWS Quizzes