How do I recover access to my Amazon EC2 instances if I've lost my SSH key pair?

Last updated: 2020-01-07

I've lost my SSH private key and am locked out of my Amazon Elastic Compute Cloud (Amazon EC2) Linux instance. How can I recover access?



  • Do not perform this procedure if your Amazon EC2 instance is instance store-backed or has instance store volumes containing data. This recovery procedure requires you to stop and start your instance, which means that data on instance store volumes will be lost. For more information, see Determining the Root Device Type of Your Instance.
  • Be aware that if your instance uses a public IP address, the address will change after the stop and stop of the instance.

To recover access to your Linux instance using AWS Systems Manager Automation, run the AWSSupport-ResetAccess Automation document. For more information, see Walkthrough: Reset Passwords and SSH Keys on Amazon EC2 Instances.

Or, to manually recover access to your Linux instance, create a new key pair to replace the lost key pair. For more information, see Connecting to Your Linux Instance If You Lose Your Private Key.