Where is my pem key file on EC2?

10,036

Solution 1

It is called a keypair because it has private key and public key. The pem key (private key) file is on your local PC. The EC2 machine has only the public key.

If you want to scp from one EC2 to another EC2 instance that are launched using the same keypair, you have to transfer your pem key file to one of your EC2 machines. It is not a good practice to keep your private key on a EC2 machine unless absolutely necessary. Using a passphrase to protect your private key provides a layer of security.

If you decide to transfer your private key to an EC2 instance, make sure you delete it from the EC2 instance when you no longer need the key.

Solution 2

Looks like you lost your pem file. It is your private key which got created on launching the instance. Do you remember downloading it? If yes then please do a search / find on your pc to search any file with ".pem". If you still cannot locate then I would suggest you to terminate the instance and launch a new instance then you would get to choose to create a new pem file and this time make sure you download the pem file and make a note of the location on your PC. The default download location would be your "Downloads" directory on windows.

Share:
10,036
Tony
Author by

Tony

Updated on June 08, 2022

Comments

  • Tony
    Tony almost 2 years

    I need to know the location of my pem key file on EC2. I have one on my PC which I downloaded when I lunch my EC2. When I transfer files between 2 EC2 instances I need to specify the location of the pem file on EC2.

    But where is this pem file stored on my EC2 instance?

  • Tony
    Tony over 7 years
    Using a passphrase to protect your private key. How is this done? Thanks
  • helloV
    helloV over 7 years
    @Tony you cannot use a passphrase if you create a keypair in AWS console. Use ssh-keygen (linux.die.net/man/1/ssh-keygen) to generate a keypair with a passphrase and then import the public key to Amazon EC2: docs.aws.amazon.com/AWSEC2/latest/UserGuide/…