Sammy AbuKmeil
Sammy AbuKmeil

Reputation: 103

Lost access to EC2 instance

I reformatted my macbook and completely forgot to copy my ~/.ssh directory.

I tried ssh'ing into my EC2 instance

$ ssh [email protected] -i xxx.pem -v
OpenSSH_8.1p1, LibreSSL 2.7.3
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 47: Applying options for *
debug1: Connecting to xx.xxx.xxx.xx [xx.xxx.xxx.xx] port 22.
debug1: connect to address xx.xxx.xxx.xx port 22: Operation timed out
ssh: connect to host xx.xxx.xxx.xx port 22: Operation timed out

But I presume it's not working because my PEM file is linked to the id_rsa file on my old laptop?

I had the PEM file in my google drive.

I've tried

Any ideas how I can regain access to my EC2 insance?

I would generate a new key pair as explain here, but it requires me to have access to the instance

Upvotes: 0

Views: 362

Answers (1)

anemyte
anemyte

Reputation: 20176

Update: check @jordanm comment. You have no connection to the instance, maybe there is no need to create a new one.

As far as I know there is only way to create a new one. You can keep data if you make an image of your existing instance. You may have changed external IP if your instance has no elastic IP attached.

  1. Login to AWS Console
  2. Create a new key pair.
  3. Select your EC2 instance in the list, in the top-left corner select Actions -> Image and templates -> Create image. Fill the form to create an image.
  4. Launch a new instance using the image you've created and your new key.
  5. (optional) If everything is in place consider terminating the original instance using console.

Upvotes: 1

Related Questions