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

Lars Nordin Lars.Nordin at SDlabs.se
Mon Sep 10 15:23:48 EST 2012


On 2012-09-10 05:36, Damien Miller wrote:
> 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
>
>
Damien,

My bad, thank you!

I wrote the patch for openssh 4.7 with some other changes. In 6.1 I just 
patched without trying to see if the new options would work (the projekt 
only needed this changes, so I thought it was easy to send in an patch)

Regards
/Lars


More information about the openssh-unix-dev mailing list