在CentOS上将PUB密钥转换为PKCS8格式?

在Ubuntu中,我可以通过命令将PubKey从OpenSSH格式转换为PKCS8格式:

ssh-keygen -e -f .ssh / id_rsa.pub -m PKCS8

但在CentOS 6.4中,当我执行相同的命令时,它注意到:

ssh-keygen:非法选项 – m

我在Centos 6.4上阅读了ssh-keygen的man-page,发现它没有选项“-m”。 那么,我怎样才能在Centos 6.4上完成同样的任务呢?

非常感谢你!

在RHEL系统和衍生产品中,您可以使用openssl执行此任务:

 # openssl pkcs8 --help Usage pkcs8 [options] where options are -in file input file -inform X input format (DER or PEM) -passin arg input file pass phrase source -outform X output format (DER or PEM) -out file output file -passout arg output file pass phrase source -topk8 output PKCS8 file -nooct use (nonstandard) no octet format -embed use (nonstandard) embedded DSA parameters format -nsdb use (nonstandard) DSA Netscape DB format -noiter use 1 as iteration count -nocrypt use or expect unencrypted private key -v2 alg use PKCS#5 v2.0 and cipher "alg" -v1 obj use PKCS#5 v1.5 and cipher "alg" -engine e use engine e, possibly a hardware device. 

此外, pkcs8(1)页提供了几个示例。

 openssl pkcs8 -topk8 -in private.key.pem -out private.key.pk8.pem -v2 des3 

SEC.SE网站上的这个 Q / A提供了对这个过程和涉及到的密码的非常详细的描述。