Openssh 私钥转 RSA 私钥 [英] Openssh Private Key to RSA Private Key

查看:70
本文介绍了Openssh 私钥转 RSA 私钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(我使用的是 MAC)

(I am using MAC)

我的 id_rsa 以

My id_rsa starts with

-----BEGIN OPENSSH PRIVATE KEY-----

但我希望它以

-----BEGIN RSA PRIVATE KEY-----

我已将我的 id_rsa.pub 发送给服务器管理员以获取对服务器的访问权限,因此我不想生成新密钥.

I have send my id_rsa.pub to server administrator to get the access to server, so I don't want to generate a new key.

  1. 有什么方法可以将我的 id_rsa(即 openssh 私钥)转移到 RSA 私钥?(请命令.)

  1. Is there any way that I can transfer my id_rsa which is a openssh private key to a RSA private key? (command please.)

如果可以转让,是否还需要转让id_rsa.pub?(请命令.)似乎 id_rsa.pub 没有像 id_rsa 这样的标题,所以我不确定我是否也应该转移它.

If I can transfer, do I also need to transfer id_rsa.pub? (command please.) It seems id_rsa.pub doesn't have a header like id_rsa, so I am not sure if I should also transfer this.

谢谢!

推荐答案

您有一个 OpenSSH 格式的密钥并且想要一个 PEM 格式的密钥.这对我来说并不直观,但建议的转换方法是更改​​密钥的密码并同时以不同的格式写入.

You have an OpenSSH format key and want a PEM format key. It is not intuitive to me, but the suggested way to convert is by changing the password for the key and writing it in a different format at the same time.

命令如下所示:

ssh-keygen -p -N "" -m pem -f /path/to/key

它将就地更改文件,因此请备份您当前的密钥以防万一.-N "" 会将密码设置为无.我还没有用密码测试过这个.

It will change the file in place, so make a backup of your current key just in case. -N "" will set the passphrase as none. I haven't tested this with a passphrase.

公钥应该没问题.

有关上述命令的完整说明,请参阅此处的 -m 选项:https://man.openbsd.org/ssh-keygen#m

For full explanation of the above command, see the -m option here: https://man.openbsd.org/ssh-keygen#m

这篇关于Openssh 私钥转 RSA 私钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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