Patch for ssh-keygen to allow conversion of public key to openssh format

Damien Miller djm at mindrot.org
Mon Sep 10 13:36:59 EST 2012


On Sun, 9 Sep 2012, Lars Nordin wrote:

> Hi,
> 
> I needed to convert a public RSA key to autorized_keys format and found
> ssh-keygen lacking this feature.
> 
> I made the option -Q publicfile to allow an conversion like
> ssh-keygen -Q pubrsa.pem -y
> 
> The patch is produced using unified diff and made on latest release.

I think you can do this already:

[djm at fuyu ~]$ openssl genrsa 1024 > /tmp/k.key
Generating RSA private key, 1024 bit long modulus
..........................++++++
............................................++++++
e is 65537 (0x10001)
[djm at fuyu ~]$ openssl rsa -pubout < /tmp/k.key > /tmp/k.pub 
writing RSA key
[djm at fuyu ~]$ cat /tmp/k.pub                                                   
-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCU7vN7q9f9bHiAYdxvyyGAwGgS
LmVxczjf8V+YArEIcAuv8hHR4PkvXS4oWBJyUlNbRxr419NLAVcHmo1Pdnnxqan+
p2HO5n16Syy9eKtJ2/SKYjJlTDh9EdR3Xr2uDYziDcpT30EIhUn9soAX21lILaxo
RFmlsTOOnXFwf9PweQIDAQAB
-----END PUBLIC KEY-----
[djm at fuyu ~]$ ssh-keygen -i -f /tmp/k.pub -m pkcs8
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQCU7vN7q9f9bHiAYdxvyyGAwGgSLmVxczjf8V+YArEIcAuv8hHR4PkvXS4oWBJyUlNbRxr419NLAVcHmo1Pdnnxqan+p2HO5n16Syy9eKtJ2/SKYjJlTDh9EdR3Xr2uDYziDcpT30EIhUn9soAX21lILaxoRFmlsTOOnXFwf9PweQ==

-d



More information about the openssh-unix-dev mailing list