Extract public/private key from PKCS12 file for later use in SSH-PK-Authentication
作者:互联网
Extract public/private key from PKCS12 file for later use in SSH-PK-Authentication
回答1
You can use following commands to extract public/private key from a PKCS#12 container:
-
PKCS#1 Private key
openssl pkcs12 -in yourP12File.pfx -nocerts -out privateKey.pem
-
Certificates:
openssl pkcs12 -in yourP12File.pfx -clcerts -nokeys -out publicCert.pem
回答2
因为私钥在保存的时候,同时存储了公钥的信息,所以从私钥里面提取公钥的信息
This is possible with a bit of format conversion.
To extract the private key in a format openssh can use:
openssl pkcs12 -in pkcs12.pfx -nocerts -nodes | openssl rsa > id_rsa
To convert the private key to a public key:
openssl rsa -in id_rsa -pubout | ssh-keygen -f /dev/stdin -i -m PKCS8
To extract the public key in a format openssh can use:
openssl pkcs12 -in pkcs12.pfx -clcerts -nokeys | openssl x509 -pubkey -noout | ssh-keygen -f /dev/stdin -i -m PKCS8
标签:use,file,later,openssl,pkcs12,private,key,public 来源: https://www.cnblogs.com/chucklu/p/15664636.html