1. Open AWS Management Console.
2. Search and open EC2.
3. Select Key Pairs under Network & Security.
4. Click Create Key Pair.
5. Enter the Key Pair Name.
6. Select RSA as the Key Pair Type.
7. Select .pem as the Private Key Format.
8. Click Create Key Pair.9. The .pem file will be automatically downloaded to your computer.
or
we can also create the key pair while creating the instance.
EC2 -> under Key Pairs -> Select Key Pairs -> Enter the Key Pair Name -> Select RSA as the Key Pair Type -> Select .pem as the Private Key Format -> Click Create Key Pair.
The key pair will be generated and the .pem key will be downloaded in the machine.