OpenSSLを使って秘密鍵を作成するのは、コマンド一発です。下例は 2048 bit 強度 RSA秘密鍵の作成コマンドです。
$ openssl genrsa -out private.key 2048
実行例
$ openssl genrsa -out private.key 2048
Generating RSA private key, 2048 bit long modulus
........................................................+++
.........+++
e is 65537 (0x10001)
作成されたか確認(サンプル)
$ cat private.key
-----BEGIN RSA PRIVATE KEY-----
MIIEpQIBAAKCAQEAx3SaJdDxIAgdlC2rRETvWokFgfEruTKNFp3LzBDuh0cSYHqB
s1rWHsIGFf2uPOSiq7M6Plr8ClccWQJjw1T0b8JVIv9dqOKk5grhBstrvVT9H39Y
BSH3f89XE62UFoMIpbk4tfZV+O8CSZpyV5iAwmw3mgwL3LJlC3i3nkDg9QP3vBNv
m3ZbzCnRRCuwXOvKjNF3NRgTAnxnnIPHizBJuiV9iC75vOL3uyq4EciWgCBF5Yn6
VyhPuDOSWOK3PGoVGRIhxC0FC/W0NVvW+F5llszuioYKXvZ6LGKAph0urJLDA5Xm
PXTkCVYZaaKlHPi13EGNWQxlPHwsNnw9Ss+o3wIDAQABAoIBAQCmMnnzwtv5FeoX
u8o3M73CUeSd9yi4w++ehdP4ca9gV49vhwUmPy2mKYRKtLyIDvehXNHOfaAAub9s
R7p7XAHmUicA54rSnDBNY4lIUR6wf+3/XewpMrl57XogcoWwEHWXKfSgYugWaooc
bK6UYQYBe40FNr53osrhuTA/lM4eOjxasbGFLLHznWpi9RS16FgosYdc7XC48Vxx
n2zuTztQn254kNNfXCHN7R/jNMPHSfALW4HIwrwsiEhvKxeWMGcrxfUAANk3mJxo
30VBDtZMSaXqprMhee2Pf8/lSdgPHo1xnghLgzHF15FCwVKm7gOR74Vhi8/iBeEH
ClP0F0+RAoGBAOnDAV6QXJoAuQB9IQm1pBl3inheOG/TK98dAZlh1a/j7oPEIxla
BY8OkraCYJVkosuLkQWIpvgCjgQ73coqSS+jj+wuIxrVHyX4vGqqYlphV2sJiM+y
A50kv5WgMNswWR2JuzGnTVoT+b6B82JZt36yKE9J21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