Linux command
openssl-genpkey 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Generate RSA private key
openssl genpkey -algorithm RSA -out [private.key] -pkeyopt rsa_keygen_bits:[4096]
Generate EC private key
openssl genpkey -algorithm EC -out [private.key] -pkeyopt ec_paramgen_curve:[P-256]
Generate Ed25519 key
openssl genpkey -algorithm ED25519 -out [private.key]
Generate encrypted private key
openssl genpkey -algorithm RSA -out [private.key] -aes256
Generate with custom parameters
openssl genpkey -algorithm RSA -out [key.pem] -pkeyopt rsa_keygen_bits:2048 -pkeyopt rsa_keygen_pubexp:65537
说明
openssl genpkey generates private keys for various algorithms. It's the modern replacement for algorithm-specific commands like genrsa and ecparam. Supports RSA, EC, ED25519, ED448, X25519, X448, and more.
参数
- -algorithm _alg_
- Key algorithm.
- -out _file_
- Output file.
- -outform _format_
- Output format (PEM, DER).
- -aes256, -aes128
- Encrypt output.
- -pkeyopt _opt:val_
- Algorithm options.
- -pass _arg_
- Output passphrase.
FAQ
What is the openssl-genpkey command used for?
openssl genpkey generates private keys for various algorithms. It's the modern replacement for algorithm-specific commands like genrsa and ecparam. Supports RSA, EC, ED25519, ED448, X25519, X448, and more.
How do I run a basic openssl-genpkey example?
Run `openssl genpkey -algorithm RSA -out [private.key] -pkeyopt rsa_keygen_bits:[4096]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -algorithm _alg_ do in openssl-genpkey?
Key algorithm.