Convert pem key to ssh-rsa format

Damien Miller djm at mindrot.org
Fri Jun 19 19:52:32 EST 2009


On Thu, 18 Jun 2009, Adriana Rodean wrote:

> Hi
> 
> I have a certificate in der format, from it with this command i
> generate a public key:
> 
> openssl x509 -inform der -in ejbcacert.cer -noout -pubkey > pub1key.pub
> 
> result is this:
> 
> -----BEGIN PUBLIC KEY-----
> MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC7vbqajDw4o6gJy8UtmIbkcpnk
> O3Kwc4qsEnSZp/TR+fQi62F79RHWmwKOtFmwteURgLbj7D/WGuNLGOfa/2vse3G2
> eHnHl5CB8ruRX9fBl/KgwCVr2JaEuUm66bBQeP5XeBotdR4cvX38uPYivCDdPjJ1
> QWPdspTBKcxeFbccDwIDAQAB
> -----END PUBLIC KEY-----
> 
> How can i obtain a public key like this? Either from certificate or
> from this public key?

I'm not sure of what you are after: an OpenSSH public key, a PEM public
key or something else?

You can extract a PEM public key from an OpenSSH private key using:

openssl rsa -pubout -in .ssh/id_rsa

But OpenSSH has no tools to convert from or too PEM public keys (note: PEM
private keys are OpenSSH's native format for protocol 2 keys).

-d


More information about the openssh-unix-dev mailing list