How to Get an AWS Public Key from a Private Key

If you create an SSH key using the AWS management console, you have probably noticed that the public key is not available to download.

The above behaviour is normal, and to retrieve the key, we need to follow the following process.

Private Key to Public Key

To get the public key from the AWS private key, download the private key to your machine. The public key will have a .pem file extension.

From your terminal (Windows, Linux or macOS run the following command against the downloaded key.

Note: On a Linux or Mac machine, you will need to run the following command first chmod 400 awsec2.pem

If you use a Windows machine, use the PowerShell console to run the command.

ssh-keygen -y -f aws_ec2.pem

The output will display the public key.