Generate Rsa Keys Without Prompt

In this article you’ll find how to generate CSR (Certificate Signing Request) using OpenSSL from the Linux command line, without being prompted for values which go in the certificate’s subject field.

Solved: I have a Cisco 1811W running 12.4(6)T2 (c181x-advipservicesk9-mz.124-6.T2.bin), and I'm wanting to turn off telnet access to it and turn on SSH which I usually do on all the routers I manage, but on this particular router when I put in the. You could do as minitech suggested and use the same SSH public key on both servers. To do so, open the file /.ssh/idrsa.pub in your text editor, copy the contents of the file exactly without adding any new spaces or newlines, and add this to the server you want to connect to.

Below you’ll find two examples of creating CSR using OpenSSL.

In the first example, i’ll show how to create both CSR and the new private key in one command.

And in the second example, you’ll find how to generate CSR from the existing key (if you already have the private key and want to keep it).

Both examples show how to create CSR using OpenSSL non-interactively (without being prompted for subject), so you can use them in any shell scripts.

Create CSR and Key Without Prompt using OpenSSL

Use the following command to create a new private key 2048 bits in size example.key and generate CSR example.csr from it:

OptionDescription
openssl reqcertificate request generating utility
-nodesif a private key is created it will not be encrypted
-newkeycreates a new certificate request and a new private key
rsa:2048generates an RSA key 2048 bits in size
-keyoutthe filename to write the newly created private key to
-outspecifies the output filename
-subjsets certificate subject

Generate CSR From the Existing Key using OpenSSL

Use the following command to generate CSR example.csr from the private key example.key:

OptionDescription
openssl reqcertificate request generating utility
-newgenerates a new certificate request
-keyspecifies the file to read the private key from
-outspecifies the output filename
-subjsets certificate subject

Automated Non-Interactive CSR Generation

The magic of CSR generation without being prompted for values which go in the certificate’s subject field, is in the -subj option.

-subj argReplaces subject field of input request with specified data and outputs modified request. The arg must be formatted as /type0=value0/type1=value1/type2=…, characters may be escaped by (backslash), no spaces are skipped.

The fields, required in CSR are listed below:

Generate Rsa Keys Without Prompt File

FieldMeaningExample
/C=CountryGB
/ST=StateLondon
/L=LocationLondon
/O=OrganizationGlobal Security
/OU=Organizational UnitIT Department
/CN=Common Nameexample.com

You’ve created encoded file with certificate signing request.

How To Generate Rsa Keys

Now you can decode CSR to verify that it contains the correct information.

SSH, the secure shell, is often used to access remote Linux systems. But its authentication mechanism, where a private local key is paired with a public remote key, is used to secure all kinds of online services, from GitHub and Launchpad to Linux running on Microsoft’s Azure cloud.

/gitlab-generate-ssh-key-putty.html. Generating these keys from Linux is easy, and thanks to Ubuntu on Windows, you can follow the same process from Windows 10. But even without Ubuntu, SSH keys can also be generated with the free and open source Windows application, PuTTy

Over the following few steps, we’ll guide you through the process of generating SSH keys using both Ubuntu on Windows and PuTTY.

Generate Rsa Keys Without Prompt Code

Requirements

All you need is a PC running Windows 10 and either of the following installed:

Generate Rsa Keys Without Prompt Key

  • The puttygen.exe executable from PuTTY

Generate Rsa Keys Without Prompt Code

If you don’t already have Ubuntu on Windows, take a look at our Install Ubuntu on Windows 10 tutorial.