macOS下使用OpenSSL生成私钥和公钥

➜ ~ openssl
OpenSSL> genrsa -out rsa_private_key.pem 1024
Generating RSA private key, 1024 bit long modulus
........................................++++++
...++++++
e is 65537 (0x10001)
OpenSSL> pkcs8 -topk8 -inform PEM -in rsa_private_key.pem -outform PEM –nocrypt
Enter Encryption Password:
Verifying - Enter Encryption Password:
-----BEGIN ENCRYPTED PRIVATE KEY-----
MIICoTAbBgkqhkiG9w0BBQMwDgQIDnWOIsDV2gMCAggABIICgLCTWnXJCzOA4rCK
XDl42wDrbznWjlqe1MPehu0gsJ9Mvb66rHCaNv6IsMP/AR/mSSDwFTRjeuOE3bf6
... ...
0mCjl+8ZwZ9M1d8b50TUNtWogLRcU83LP3KtAjUTw2dKOsXoO0q3pXTGkme87/NA
S/ibPmY=
-----END ENCRYPTED PRIVATE KEY-----
OpenSSL> rsa -in rsa_private_key.pem -pubout -out rsa_public_key.pem
writing RSA key
OpenSSL> exit
➜ ~ ls *.pem
rsa_private_key.pem rsa_public_key.pem
➜ ~

PS. SSH加密可以参考这篇文章

你可能感兴趣的:(macOS下使用OpenSSL生成私钥和公钥)