How to Generate Certificate Signing Request (CSR) on Linux

CSR stands for ‘Certificate Signing Request’, that is generated on the server where the certificate will be used on. A CSR contains information about to your organization and domain name, locality, and country and a public key that will be included in your certificate.

This article has 3 methods to create CSR (Certificate Signing Request) on Linux systems. You can choose any one of below methods. All methods will do the same task, only they have a detailed explanation.

Method 1 – Using Single Command

We can create CSR using the single command like below. But make sure you have installed OpenSSL package on your system. The below command will first create a private key and then generate CSR. This command will also require few details as input.

openssl req -new -newkey rsa:2048 -nodes -keyout pardishosting.com.key  -out pardishosting.com.csr 

above command create csr and key file on your current directory.

Method 2 – Short Instructions

Below are three simple commands to generate CSR. You may also use detailed instructions to do it.

sudo yum install openssl         ## Redhat based systems  
sudo dnf install openssl         ## Fedora systems  
sudo apt install openssl         ## Debian based systems 
openssl genrsa -out pardishosting.com.key 2048 
openssl req -new -key pardishosting.com.key -out pardishosting.com.csr 

Method 3 – Detailed Instructions

Step 1: Install Required Packages

In order to generate CSR, you required OpenSSL to be installed on your system. If it is not already installed use below command to install it.

sudo yum install openssl         ## Redhat based systems  
sudo dnf install openssl         ## Fedora systems  sudo apt-get install openssl     ## Debian based systems 

Step 2: Generate Key for your Domain.

Firstly you required root access to generate a key file. So login as root and use below command to generate a key.

openssl genrsa -out pardishosting.com.key 2048 

Sample output:

Generating RSA private key, 2048 bit long modulus
........................................+++
....................................................+++
e is 65537 (0x10001)

 

At the end of the command, it showing 2048, which is the length of the key in bits. Most of CA required 2048 bit length keys. Above command will create a key file tecadmin.net.key, which is used in step 3.

Step 3: Generate CSR for your Domain using Key

After generating a key, next steps are to generate CSR for the domain. Use below command to generate CSR file, This command will prompt for your organization and common name, locality, email, and country. Common Name must be the same as your domain name.

openssl req -new -key pardishosting.com.key -out pardishosting.com.csr 

 

Sample Output:

You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]: IN
State or Province Name (full name) []: Uttar Pradesh
Locality Name (eg, city) [Default City]: Lucknow
Organization Name (eg, company) [Default Company Ltd]: Pardis Pvt Ltd
Organizational Unit Name (eg, section) []: BLOG
Common Name (eg, your name or your server's hostname) []: pardishosting.com
Email Address []: admin@pardishosting.com

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:

Above command will generate a file pardishosting.com.csr in the current directory, Use this file to order your SSL from CA (Certificate Authority).

Leave a Reply

Your email address will not be published. Required fields are marked *