amazon-web-servicessecurityubuntuamazon-ec2ssh

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?


Solution

  • 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.

    For more information follow this doc.