Guides SSL

Generate a certificate signing request from the command line

Create the CSR and private key an SSL certificate order asks for, using OpenSSL on your server.

Updated October 31, 2026

SSH into your server, then go to your ssl directory, or create it and go into it.

cd ssl #Navigate
mkdir ssl && cd ssl #Create & Navigate

Go to the csrs directory, or create it and go into it.

cd csrs #Navigate
mkdir csrs && cd csrs #Create & Navigate

Run the following command. Replace domainname with your domain name without its extension: if your domain is sample.com, enter sample. For a stronger private key, use rsa:4096.

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

The output should look similar to this, followed by a prompt to start entering data.

Generating a 2048 bit RSA private key ..........................+++
..+++
writing new private key to 'domainname.key'
-----
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.
-----

Enter the following at each prompt.

  • Country Name (required)
    • The two-letter abbreviation for your country. For example United States would be “US” and Great Britain would be “GB”.
  • State or Province Name (required)
    • Enter the full name of the state your organization operates from. For example, “California” or “New York”.
  • Locality Name (required)
    • Enter the name of the city your organization operates from. For example, “Los Angeles” or “New York City”. If your city has abbreviations, please provide the full name. For example, “Saint Paul” instead of “St. Paul”
  • Organization Name (required)
    • The name of your organization. If you are a business, provide the legal name of the business. If you are an individual, provide your full name.
  • Organizational Unit Name (optional)
    • If you are a business, your “Doing Business As” (DBA) name if you have one. Alternatively, you can enter a department name. For example, “IT Department” or “Web Administration”.
  • Common Name (required)
    • Enter the domain name with extension (e.g. sample.com). If you are generating a CSR for a wildcard SSL, enter it as *.sample.com.
  • Email Address
    • A contact email address for your organization.
  • A challenge password (optional)
  • An optional company name (optional)

Once you have entered everything above, the certificate request is created in the csrs directory.

There are now two files, domainname.csr and domainname.key, named after your domain. Show the contents of domainname.csr with this command.

cat domainname.csr

Copy the whole output, including the -----BEGIN CERTIFICATE REQUEST----- and -----END CERTIFICATE REQUEST----- lines. Keep domainname.key private and on the server: the certificate will not work without it.