Can openssl convert SSH public key to a PEM file without private key?

6,069

If you are just looking to convert a public key, not create a certificate then you only need the public key.

ssh-keygen -f id_rsa.pub -e -m pem > id_rsa.pub.pem

Will read a public key file id_rsa.pub (containing just your friend's public key) and convert it to pem format.

The private key would be needed for something like a self signed certificate (in x509 format) because it's the private key that generates the signature.

Share:
6,069

Related videos on Youtube

Praveen Premaratne
Author by

Praveen Premaratne

Updated on September 18, 2022

Comments

  • Praveen Premaratne
    Praveen Premaratne over 1 year

    So I've seen many many posts on how to do the conversion with private key; but does anyone one know how I can do this with just only public key? As I'm trying to convert someone else's public key.

    Or is this something not possible and I need to ask them to generate one themselves?

    • Philip Couling
      Philip Couling about 5 years
      PEM format can wrap up a few different things. Could you clarify. Are you trying to create a certificate (x509) or are you just trying to convert the public key format?
    • Арсений Черенков
      Арсений Черенков about 5 years
      are you trying to get a private key from a public key ? assymetric key were meant to make this impossible. Could you give more details ?
  • Praveen Premaratne
    Praveen Premaratne about 5 years
    Thank you; this is what I was looking for.