31

Running "ssh-keygen -t dsa" generates two files, a private and public key. Its simple enough to comprehend that the private key is used to identify yourself to the outside world, which only sees your public key.

However, I've also seen ".pem" files used as well, and I use them myself. Whats the relationship between the .pem file and pub files. I was hoping for a simple answer, but other questions (https://serverfault.com/questions/9708/what-is-a-pem-file-and-how-does-it-differ-from-other-openssl-generated-key-file) seem to indicate that there is no simple explanation for why a pem file might be better/worse in different scenarios to a pub file.

1
  • The real answer is: it's just a hassle
    – Randy L
    May 17, 2020 at 20:13

2 Answers 2

18

.pub file format is used by SSH for public key store, this key need to share with a Server.

.pem(Privacy Enhanced Mail) is a base64 container format for encoding keys and certificates. .pem download from AWS when you created your key-pair. This is only a one time download and you cannot download it again.

.ppk(Putty Private Key) is a windows ssh client, it does not support .pem format. Hence you have to convert it to .ppk format using PuTTyGen.

non suffixed ssh file is a private key


Convert PEM to PPK file format

puttygen server.pem -O private -o server.ppk

Create a PEM from a PPK file

puttygen server.ppk -O private-openssh -o server.pem  
3
  • chiark.greenend.org.uk/~sgtatham/putty says Putty is for both Windows and Unix Platforms. May 11, 2020 at 14:45
  • 1
    Was the Question somehow specific to AWS or PPK? I'm trying to understand the relevancy here.
    – cellepo
    Jul 8, 2020 at 1:34
  • This answer could tell us how to create a .pub file. My server (cPanel) gives me a certificate and a private key, so I'd like to know how to create all the other formats from those two. Feb 1, 2021 at 16:46
3

In SSH connections, keys are exchanged.

key1 is the private key and key.pub is the public key.

Read more at: Public-key cryptography

The .pem files are certificates (in base64), exchanged in HTTPS protocol (TLS/SSL). Read more at: X.509

2
  • 13
    Seriously? Wikipedia links? Hardly better than linking to google search results...
    – odigity
    Jul 15, 2014 at 18:02
  • 1
    Didn't even link to the English version for the second one.
    – ealdent
    Aug 31, 2015 at 15:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .