I tried to use putty also. I select this pem key there and got this:

Unable to use key file "key.pem" (not a private key).

I read that it is possible to convert a pem to a pub key. I did it like there:

  1. Convert pem key to ssh-rsa format

  2. How can I convert a PEM key into a RSA key pair?

But I got the same error when trying to connect.

  • 3
    It'd probably help if you posted the "same error" you got. Also, if possible, add an excerpt of the SSH log (usually /var/log/auth.log; if you have admin privileges on the server, try to up the verbosity of SSH's logging while you're at it) to the question. Help us help you.
    – Shadur
    Feb 14, 2012 at 9:33
  • 2
    Also, why are you trying to do this? There's very little advantage to generating an ssh keypair from an existing key vs. just generating a new keypair.
    – larsks
    Feb 14, 2012 at 22:41
  • Can you provide the output of file key.pem (this is a *nix command, not windows).
    – phemmer
    Feb 25, 2012 at 4:57

4 Answers 4


(Partial answer but too many links for reasonable comment.)

putty doesn't use PEM format (like OpenSSL and OpenSSH), instead its own format PPK. Run puttygen and it can Load (or Import) private-key from PEM and Save to PPK. Partial dupe of:

Can I use an SSH key generated on Linux from Putty?

What difference between openssh key and putty key?

Convert Amazon .pem key to Putty .ppk key Linux



The PEM format can contain more than one key. There are often more then one public keys or a key-pair concatenated together. For ssh you have a key-pair id_rsa is the private key in PEM format. id_rsa.pub is your public key.

It is not possible to convert a private key to public key, except of some brute force hacking. To connect to another host using the keys, you need to copy your public key to other host by using ssh-copy-id. The sshd server should have PubkeyAuthentication enabled.

  • 2
    "It is not possible to convert a private key to public key". That is not true: ssh-keygen -f ~/.ssh/id_rsa -y
    – phemmer
    Mar 10, 2014 at 3:18
  • Well, thats a "private OpenSSH format file" and it contains the private and the public key so you are not converting anything there. I wrote that a PEM format can contain more than one key, you just pull the other key from the file.
    – user55518
    Mar 10, 2014 at 3:58
  • 1
    You should disambiguate that in your answer. The very last thing you talk about before that sentence is id_rsa and id_rsa.pub.
    – phemmer
    Mar 10, 2014 at 6:25

inside the .pem there is a section for private key, you can just take that and put it into a .key file (the other section would go in your .crt) then you have your .crt and your .key. i have no idea if you can use that .key with ssh though.. i dont see why not.. just try naming it appropriately

cat blah.key > ~/.ssh/id_rsa
cat blah.crt > ~/.ssh/id_rsa.pub

copy it to remotemachine and

cat id_rsa.pub >> ~/.ssh/authorized_keys
  • SSH does not use certificates, and OpenSSH .pub format is not PEM at all. It is possible to extract the pubkey from the X.509 cert with openssl as PEM and then convert it to openssh per stackoverflow.com/questions/1011572/… but since you have the private key it's much easier to just extract with ssh-keygen -y . Apr 29, 2014 at 9:56

pem file is probably a ssl certificate - this is something else than openssh key.

So - you can't use it.

You must log in to answer this question.

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