I've converted an rsa key to pem using the following command

openssl rsa -in ~/.ssh/id_rsa -outform pem > id_rsa.pem

However when I try uploading this key to my ubuntu server hosted on Azure I get an error

The certificate is in an invalid format. X.509 standard format in a .cer or .pem file is supported.

What is the correct way of converting an rsa key to pem format?

  • Are you sure you didn't get any errors using this command? Is your id_rsa.pem empty? May 13, 2014 at 8:33
  • It is not empty
    – chris
    May 13, 2014 at 8:37
  • How would you do your conversion though?
    – chris
    May 13, 2014 at 8:37
  • This method is working for me. What are you trying to do with it? May 13, 2014 at 8:49
  • 1
    Azure only accepts .pem or .cer keys so I can't use my id_rsa key
    – chris
    May 13, 2014 at 8:52

1 Answer 1


From the Azure site itself:

openssl req -x509 -key ~/.ssh/id_rsa -nodes -days 365 -newkey rsa:2048 -out id_rsa.pem

This will convert your private key into a public key that can be used with Azure.

You must log in to answer this question.

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