May 13, 2019 · First, you have to generate a private key, and then generate CSR using that private key. Step 1: Generate a private key. Enter the following command in the Terminal with sudo to generate a private key using RSA algorithm with a key length of 2048 bits. $ sudo openssl genrsa –out domain.key 2048. Replace domain with your own domain name. Above command will generate a private key named domain.key and place it in your current directory.