Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find AWS keypair public key?

So, it seems a developer on our team deleted the public key for our App-Production.pem key in our .ssh/authorized_keys, so the default AWS Key Pair no longer works, breaking our deployment pipeline.

Where can I find the public key to add back to authorized_keys? Is it possible to do this without having to boot a fresh instance?

like image 271
j_d Avatar asked Jul 19 '17 18:07

j_d


1 Answers

If you have the private key, you can retrieve the public key.

If you are using Linux, use following command,

ssh-keygen -y

Then provide your path to private key file when prompted. After that you will be given a public key. Save it.

Then use following steps to regain access to this instance.

  • Stop your instance
  • Detach root volume
  • Attach volume to another instance as a data volume
  • Modify the authorized_keys file with the public key
  • Detach the data volume
  • Re attach the volume to the affected instance

For more information follow this doc.

like image 78
Rumesh Eranga Hapuarachchi Avatar answered Oct 07 '22 02:10

Rumesh Eranga Hapuarachchi