V
V
Vlad2017-06-14 11:46:51
SSH
Vlad, 2017-06-14 11:46:51

How to generate Private Public Key?

I'm not good at this - please help me understand.
I need to get private and public keys for my server where the site is located.
How do I do it based on the instructions found on the Internet.
1) openssl genrsa -out privkey.pem 1024
2) openssl req -new -key privkey.pem -out request.pem "privkey.pem"
Question #1: I end up with an error "unknown option privkey.pem" - what's wrong?
Question number 2: Using the above commands, you can generate a private key and sort of like a file for a request for a certificate.
How to get public key?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Grishin, 2017-06-14
@vesper-bot

Private key and public key are an inextricable pair, they are generated by the first command. The privkey.pem file will contain both private and public keys.
About the options - read openssl --help or just remove "privkey.pem" from the line, it seems like only -key and -out are enough to start, and then you will enter the data for the request to the CA manually.

C
CityCat4, 2017-06-14
@CityCat4

All wrong. :) Throw out these century-old manuals and read man req
I understand that you need an SSL certificate. Are you generating a self-signed or create request to an external CA?
If you are generating a self-signed one, then the command:
will create a certificate for you with an RSA key of 2048 bits, which is enough for now :) and serial number 0 (if you want a random number, remove the set_serial parameter) located in the test.crt and test.key files. The first is the actual certificate (public key), the second is the key. They are always generated in pairs - using a certificate with someone else's key will not work. During the generation process, openssl will request the data entered into the certificate, if it doesn’t matter, you can stupidly press Enter
If you are generating a request to an external CA, then the command:
will generate a certificate request in the test.pem file and a key to this request in the test.key file. openssl will again ask questions, answer them - in the event that the request goes to generally recognized CAs like Thawte, you need to be careful , if to a corporate one - in accordance with the CP of this CA, they may not require filling at all.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question