【问题标题】:Unable to encrypt private key using openssl无法使用 openssl 加密私钥
【发布时间】:2019-08-15 18:20:47
【问题描述】:

我已经使用 openssh 生成了 Rsa 密钥对。我想使用 openssl 使用密码加密私钥。

我尝试使用 openssl 加密私钥,但无法这样做,因为它会给出错误消息。

使用以下命令生成 rsa 密钥对

ssh-keygen -t rsa -b 4096 -P ''-f ./Test-key

在下面的命令中使用 openssl 加密私钥。

rsa -des3 -in C:\Users\vkode200\Test-key -out C:\Users\vkode200\Test-key-encrypted -passout pass:"${pass}"

我收到以下错误消息:

15764:error:0906D06C:PEM routines:PEM_read_bio:no start line:crypto\pem\pem_lib.c:686:Expecting: ANY PRIVATE KEY
error in rsa```

Below is the header of my generated private key
```-----BEGIN OPENSSH PRIVATE KEY-----```
I have no clue and i spent lot of time to figure out the issue, but no luck. 

【问题讨论】:

  • 这里需要使用openssl吗? ssh-keygen 可以加密和解密 ssh 密钥。
  • 是的,我需要使用openssl,因为其他系统使用openssl des3来解密。

标签: encryption openssl private-key openssh


【解决方案1】:

您可以通过传递-m PEM 来生成旧格式的密钥:

ssh-keygen -t rsa -b 4096 -P '' -f ./Test-key -m PEM

使用 openssl 命令应该可以正常工作。

如果您需要它们的新格式,您可以制作一个副本并将其转换为:

ssh-keygen -p -P '' -N '' -f ./Test-key -m PEM

【讨论】:

  • 感谢 Yachoor 帮助我生成可以加密的 RSA 密钥。
猜你喜欢
  • 2018-02-13
  • 2017-07-07
  • 2021-02-22
  • 2020-02-28
  • 1970-01-01
  • 2016-08-26
  • 1970-01-01
  • 2016-07-03
  • 1970-01-01
相关资源
最近更新 更多