首页/安全/加密与证书速查/openssl rsa 查看与转换 RSA 密钥

openssl rsa 查看与转换 RSA 密钥

rsa 命令用于读取、检查与转换 RSA 私钥:打印参数、导出公钥、去除口令、比对模数;3.x 中仍保留该命令作为兼容入口。

加密与证书速查安全更新于 2026-10-12
查看openssl rsa -in key.pem -noout -text | head
检查-check 校验密钥一致性
导出公钥-pubout -out pub.pem
去口令-out key.plain(转换后立即改权限)

比对私钥与证书匹配

比对私钥与证书匹配
openssl rsa -in key.pem -noout -modulus | openssl dgst -sha256
openssl x509 -in cert.pem -noout -modulus | openssl dgst -sha256   # 两行一致即匹配
证书与私钥是否匹配可以直接比对模数指纹:两边输出完全一致即匹配。

易错点

  • EC 与 Ed25519 密钥不能用 rsa 命令处理
  • 去口令后的明文私钥未及时改权限与清理

数据来源与参考

  • OpenSSL 官方文档(rsa)
​‌‌​​‌​​​‌‌​‌‌‌‌​‌‌​​​‌‌​‌‌‌​​‌‌​​‌​‌‌‌​​‌‌‌​​​‌​‌‌​‌​​‌​‌‌‌​​​‌​‌‌​‌​​‌​‌‌​​​‌‌​‌‌‌​‌​​​‌‌​‌‌‌‌​​‌​‌‌‌​​‌‌​​​‌‌​‌‌​‌‌‌‌​‌‌​‌‌​‌