从 PKCS12 文件中提取公钥/私钥以供以后在 SSH-PK-Authentication 中使用 [英] Extract public/private key from PKCS12 file for later use in SSH-PK-Authentication

查看:38
本文介绍了从 PKCS12 文件中提取公钥/私钥以供以后在 SSH-PK-Authentication 中使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从我的 PKCS#12 文件中提取公钥和私钥,以便以后在 SSH-Public-Key-Authentication 中使用.

I want to extract the public and private key from my PKCS#12 file for later use in SSH-Public-Key-Authentication.

现在,我正在通过 ssh-keygen 生成密钥,并将其放入 .ssh/authorized_key,分别位于客户端的某个位置.

Right now, I'm generating keys via ssh-keygen which I put into .ssh/authorized_key, respective somewhere on the client-side.

将来,我想使用 PKCS#12 容器中的密钥,所以我必须首先从 PKCS#12 中提取公钥,然后将它们放入 .ssh/authorized_keys 文件中.有没有机会通过 openssl 让它工作?PKCS#12 中的密钥是否与 ssh-public-key 认证兼容?

In future, I want to use the keys from a PKCS#12 container, so I've to extract the public-key first from PKCS#12 and then put them into the .ssh/authorized_keys file. Is there any chance to get this working via openssl? Are the keys in PKCS#12 compatible for ssh-public-key authentication?

推荐答案

您可以使用以下命令从 PKCS#12 容器中提取公钥/私钥:

You can use following commands to extract public/private key from a PKCS#12 container:

  • PKCS#1 私钥

  • PKCS#1 Private key

openssl pkcs12 -in yourP12File.pfx -nocerts -out privateKey.pem

  • 证书:

  • Certificates:

    openssl pkcs12 -in yourP12File.pfx -clcerts -nokeys -out publicCert.pem
    

  • 这篇关于从 PKCS12 文件中提取公钥/私钥以供以后在 SSH-PK-Authentication 中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆