我正在使用已openssl
安装但未安装的系统ssh-keygen
。我无法安装新软件。我可以使用以下命令生成 SSH 密钥对openssl
:
sh-4.2$ openssl genrsa -out key.pem 2048
Generating RSA private key, 2048 bit long modulus
....................................................................................+++
...............................+++
unable to write 'random state'
e is 65537 (0x10001)
sh-4.2$ openssl rsa -in key.pem -outform PEM -pubout -out key.pub
writing RSA key
sh-4.2$ cat key.pub
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvGwJnfrGGvHyEigIdSg1
rZFhe+5412j4+bCdtmArUuBna6hXLs5CqJ+cmnUK8hHV7Z9t81vINAWqbNTEQfc6
PU9meCnk1RRQPqm8MeE+G5EDkyZUIanoWhT2yN46sMKEq3ChCW7Ubw+Q42BIrUIE
7pChkG0SH4TlgimkJHmV2ydE6gVlRw+EWbZzqK+IF8xjyDs7xCEmH04AoEV8mwcP
+JziGPiijArgf9M53DEYldVJFPXpti0CqDuW33ZQoiuwV1xnrEgu6kU0M/Ct6WTA
A2dgG8b17SSsL3AYxQy6YWQzD6bZ99U0sj9dW7BM3UPa/wlkgF0hHkFzPb1CBeoY
twIDAQAB
-----END PUBLIC KEY-----
sh-4.2$
通常我会使用ssh-keygen
它为authorized_keys
文件生成所需的 OpenSSH 格式:
sh-4.2$ ssh-keygen -f key.pub -i -mPKCS8
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC8bAmd+sYa8fISKAh1KDWtkWF77njXaPj5sJ22YCtS4GdrqFcuzkKon5yadQryEdXtn23zW8g0Baps1MRB9zo9T2Z4KeTVFFA+qbwx4T4bkQOTJlQhqehaFPbI3jqwwoSrcKEJbtRvD5DjYEitQgTukKGQbRIfhOWCKaQkeZXbJ0TqBWVHD4RZtnOor4gXzGPIOzvEISYfTgCgRXybBw/4nOIY+KKMCuB/0zncMRiV1UkU9em2LQKoO5bfdlCiK7BXXGesSC7qRTQz8K3pZMADZ2AbxvXtJKwvcBjFDLphZDMPptn31TSyP11bsEzdQ9r/CWSAXSEeQXM9vUIF6hi3
sh-4.2$
不过我ssh-keygen
在这个系统上没有。如何仅使用openssl
基本实用程序生成所需的输出?