标签:输入 mob ref host acp tin wds 指定 type
genrsa用于生成RSA私钥,不会生成公钥,因为公钥提取自私钥,如果需要查看公钥或生成公钥,可以使用openssl rsa命令。
使用man genrsa查询其用法。
openssl genrsa [-out filename] [-passout arg] [-des] [-des3] [-idea] [numbits]
选项说明:
-out filename :将生成的私钥保存至filename文件,若未指定输出文件,则为标准输出。
-numbits :指定要生成的私钥的长度,默认为1024。必须为命令行的最后一项参数。
-des|-des3|-idea:指定加密私钥文件用的算法,这样每次使用私钥文件都将输入密码,太麻烦所以很少使用。
-passout args :加密私钥文件时,传递密码的格式,如果要加密私钥文件时未指定该项,则提示输入密码。传递密码的args的格式见https://www.cnblogs.com/liliyang/p/9738929.html
例如:
(1).生成512位的rsa私钥,输出到屏幕
[root@localhost tmp]# openssl genrsa 512
Generating RSA private key, 512 bit long modulus
..........++++++++++++
...++++++++++++
e is 65537 (0x10001)
-----BEGIN RSA PRIVATE KEY-----
MIIBOgIBAAJBALuTz3ryd8qew0smTSuCKoA0G7/psj1HXLu5di8AZN+8wlJxSOYH
R1S0EXqIlpOE4ajkGDVacsdV38aQyqxY5tUCAwEAAQJAXD9W3Bn+O5FUbdLKRMlg
6We29eySEXzU6CVPL9I7yaOL0OFslvWbHXY9Zvn871lNkCpthwutJ6UsbCUKHo37
SQIhAPZfFLSQfvmePHj59+dIMs/qeVIPZWCnq0yC3KaF4hZzAiEAwuiAdC2cHNLY
KKP2sDR5kfJU/zru03m0XEHdfWp4c5cCIAb++jKKa+CguqzgxEZgCXlX+iv3XfSZ
rkaU7LkZ0iq7AiEAt9wXgICd6VrD6eJyDNoTbCeLIpD3RapjBzxisbJEGdUCIGlp
WBcMHlRG5rqk+T+ONaA2wJY7lw0N8V/BuaDVtNor
-----END RSA PRIVATE KEY-----
(2).生成512位的rsa私钥,输出到指定的文件genrsa.txt
[root@localhost tmp]# openssl genrsa -out genrsa.txt 512
[root@localhost tmp]# cat genrsa.txt
-----BEGIN RSA PRIVATE KEY-----
MIIBOwIBAAJBAM+hBmDPXongltEIy6Zkk+YhNNpGZKHzCLjWeQpd6qTSgVrST+kO
Ci1bNI/D6Lm5kYk6YNQfxzkb58JoaGhPF3MCAwEAAQJAYWnPMESaul2g5NoXki3G
JkaWIYK9XC5GfVJC39ZIbKNtphy3Cqw5FfVn7YEg/Dl1Tn/ZyWoLCapyc1Z/TRqB
oQIhAP46ZHnj3bvQJ8mK5NtyBPv1uVjicpva78ukjXtwOJ8FAiEA0RN84R2BiLnc
v3wFQ1HPJbY6ud8PvhHlaBlieuji9hcCIATGdgKwHAceFtE7UacpkhxldjDMOBjj
WOO7WIj8B6Q9AiEAn+l15IC66KawDs1/AQR7me6NcEkKM2hgvIRd7IBfx7UCIQDR
J3sGcE0mIICOTtmW2FgdvOuf2UmVO9MDXfZv6chdww==
-----END RSA PRIVATE KEY-----
(3).加密私钥文件,加密的密码为123456
[root@xuexi tmp]# openssl genrsa -out genrsa.txt -des3 -passout pass:123456 512
Generating RSA private key, 512 bit long modulus
...++++++++++++
............++++++++++++
e is 65537 (0x10001)
[root@xuexi tmp]# cat genrsa.txt
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,E9BB63C62F16598B
PJ0fTX8ywxeAfyJwMOucep6cU6Rb38MgoxWQ8VzS+iUfp5KEMdxWa24IkgQmu+Nl
uzZiuuMzvxV7yQr69xVq8VArW5jOhGyNsUSgtwUD6XsoBGerEjjHLj7C4tlLumbx
AtGCE+WmJcG3il3FgTmK4DdkwkdQmVfJt0tbpVXcl0l7iVuIMLu+oN7tuIvIcA0B
0uuWaVCYLrhCvp6zGJnPKNFbmM4YDjVwjl/Bei9iuAV7dmZhprWqfYB/oSMvEMLd
KMHmNHq38vjCGgPS9Oi7leKsMWf7PoXvT59yDm/2z0EwxJnzfOAGe2u+KqjKoRUT
yXVMfmAVeb5sZS5c57ZPmqu+MBqagVa2pwQkgVRS1sILPYSGCdmN6cJA6jztjRAD
Uz4XbIDtPe0G5Eq+OhSPc8pU33M3BVcKaNU1ulyjojM=
-----END RSA PRIVATE KEY-----
一般情况下能用到的选项也就"-out"和"numbits"
标签:输入 mob ref host acp tin wds 指定 type
原文地址:https://www.cnblogs.com/liliyang/p/9738949.html