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? – Louis Matthijssen May 13 '14 at 8:33
  • It is not empty – chris May 13 '14 at 8:37
  • How would you do your conversion though? – chris May 13 '14 at 8:37
  • This method is working for me. What are you trying to do with it? – Louis Matthijssen May 13 '14 at 8:49
  • 1
    Azure only accepts .pem or .cer keys so I can't use my id_rsa key – chris May 13 '14 at 8:52
up vote 13 down vote accepted

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.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.