Cisco Content Hub - crypto key generate rsa (2024)

To generate Rivest, Shamir, and Adelman (RSA) key pairs, use thecrypto key generate rsa commandinglobal configuration mode.

crypto key generate rsa [ general-keys |usage-keys | signature | encryption ] [ label key-label ] [exportable] [ modulus modulus-size ] [ storage devicename : ] [redundancy] [ on devicename : ]

Syntax Description

general-keys

(Optional) Specifies that a general-purpose key pair will begenerated, which is the default.

usage-keys

(Optional) Specifies that two RSA special-usage key pairs, oneencryption pair and one signature pair, will be generated.

signature

(Optional) Specifies that the RSA public key generated will be asignature special usage key.

encryption

(Optional) Specifies that the RSA public key generated will bean encryption special usage key.

label key-label

(Optional) Specifies the name that is used for an RSA key pairwhen they are being exported.

If a key label is not specified, the fully qualified domain name(FQDN) of the router is used.

exportable

(Optional) Specifies that the RSA key pair can be exported toanother Cisco device, such as a router.

modulus modulus-size

(Optional) Specifies the IP size of the key modulus.

By default, the modulus of a certification authority (CA) key is1024 bits. The recommended modulus for a CA key is 2048 bits. Therange of a CA key modulus is from 350 to 4096 bits.

Note

Effective with Cisco IOS XE Release 2.4 and Cisco IOS Release15.1(1)T, the maximum key size was expanded to 4096 bits forprivate key operations. The maximum for private key operationsprior to these releases was 2048 bits.

storage devicename :

(Optional) Specifies the key storage location. The name of thestorage device is followed by a colon (:).

redundancy

(Optional) Specifies that the key should be synchronized to thestandby CA.

on devicename :

(Optional) Specifies that the RSA key pair will be created onthe specified device, including a Universal Serial Bus (USB) token,local disk, or NVRAM. The name of the device is followed by a colon(:).

Keys created on a USB token must be 2048 bits or less.

Command Default

RSA key pairs do not exist.

Command Modes


Global configuration

Command History

Release

Modification

11.3

This command was introduced.

12.2(8)T

The key-label argumentwas added.

12.2(15)T

The exportable keyword was added.

12.2(18)SXD

This command was integrated into Cisco IOS Release12.2(18)SXD.

12.4(4)T

The storagekeyword and devicename : argument were added.

12.2(33)SRA

This command was integrated into Cisco IOS Release12.2(33)SRA.

12.4(11)T

The storagekeyword and devicename : argument were implemented on the Cisco7200VXR NPE-G2 platform.

The signature, encryption and on keywords and devicename : argument were added.

12.4(24)T

Support for IPv6 Secure Neighbor Discovery (SeND) was added.

XE 2.4

The maximum RSA key size was expanded from 2048 to 4096 bits forprivate key operations.

15.0(1)M

This command was modified. The redundancy keyword was introduced.

15.1(1)T

This command was modified. The range value for the modulus keyword value isextended from 360 to 2048 bits to 360 to 4096 bits.

Usage Guidelines

Cisco Content Hub - crypto key generate rsa (1)
Note

Security threats, as well as the cryptographic technologies tohelp protect against them, are constantly changing. For moreinformation about the latest Cisco cryptographic recommendations,see the Next Generation Encryption (NGE) whitepaper.

Use this command to generate RSA key pairs for your Cisco device(such as a router).

RSA keys are generated in pairs--one public RSA key and oneprivate RSA key.

If your router already has RSA keys when you issue this command,you will be warned and prompted to replace the existing keys withnew keys.

Cisco Content Hub - crypto key generate rsa (2)
Note

Before issuing this command, ensure that your router has ahostname and IP domain name configured (with the hostname and ip domain-name commands). You will be unable tocomplete the crypto key generate rsa commandwithout a hostname and IP domain name. (This situation is not truewhen you generate only a named key pair.)

Cisco Content Hub - crypto key generate rsa (3)
Note

Secure Shell (SSH) may generate an additional RSA key pair ifyou generate a key pair on a router having no RSA keys. Theadditional key pair is used only by SSH and will have a name suchas {router_FQDN }.server. For example, if a router name is“router1.cisco.com,” the key name is“router1.cisco.com.server.”

This command is not saved in the router configuration; however,the RSA keys generated by this command are saved in the privateconfiguration in NVRAM (which is never displayed to the user orbacked up to another device) the next time the configuration iswritten to NVRAM.

Cisco Content Hub - crypto key generate rsa (4)
Note

If the configuration is not saved to NVRAM, the generated keysare lost on the next reload of the router.

There are two mutually exclusive types of RSA key pairs:special-usage keys and general-purpose keys. When you generate RSAkey pairs, you will be prompted to select either special-usage keysor general-purpose keys.

Special-Usage Keys

If you generate special-usage keys, two pairs of RSA keys willbe generated. One pair will be used with any Internet Key Exchange(IKE) policy that specifies RSA signatures as the authenticationmethod, and the other pair will be used with any IKE policy thatspecifies RSA encrypted keys as the authentication method.

A CA is used only with IKE policies specifying RSA signatures,not with IKE policies specifying RSA-encrypted nonces. (However,you could specify more than one IKE policy and have RSA signaturesspecified in one policy and RSA-encrypted nonces in anotherpolicy.)

If you plan to have both types of RSA authentication methods inyour IKE policies, you may prefer to generate special-usage keys.With special-usage keys, each key is not unnecessarily exposed.(Without special-usage keys, one key is used for bothauthentication methods, increasing the exposure of that key.)

General-Purpose Keys

If you generate general-purpose keys, only one pair of RSA keyswill be generated. This pair will be used with IKE policiesspecifying either RSA signatures or RSA encrypted keys. Therefore,a general-purpose key pair might get used more frequently than aspecial-usage key pair.

Named Key Pairs

If you generate a named key pair using the key-labelargument, you mustalso specify the usage-keys keyword or the general-keys keyword. Namedkey pairs allow you to have multiple RSA key pairs, enabling theCisco IOS software to maintain a different key pair for eachidentity certificate.

Modulus Length

When you generate RSA keys, you will be prompted to enter amodulus length. The longer the modulus, the stronger the security.However a longer modules takes longer to generate (see the tablebelow for sample times) and takes longer to use.

Table 1 Sample Times by Modulus Length to Generate RSA Keys

Router

360 bits

512 bits

1024 bits

2048 bits (maximum)

Cisco 2500

11 seconds

20 seconds

4 minutes, 38 seconds

More than 1 hour

Cisco 4700

Less than 1 second

1 second

4 seconds

50 seconds

Cisco IOS software does not support a modulus greater than 4096bits. A length of less than 512 bits is normally not recommended.In certain situations, the shorter modulus may not functionproperly with IKE, so we recommend using a minimum modulus of 2048bits.

Cisco Content Hub - crypto key generate rsa (5)
Note

As of Cisco IOS Release 12.4(11)T, peer public RSA keymodulus values up to 4096 bits are automatically supported. Thelargest private RSA key modulus is 4096 bits. Therefore, thelargest RSA private key a router may generate or import is 4096bits. However, RFC 2409 restricts the private key size to 2048 bitsor less for RSA encryption. The recommended modulus for a CA is2048 bits; the recommended modulus for a client is 2048 bits.

Additional limitations may apply when RSA keys are generated bycryptographic hardware. For example, when RSA keys are generated bythe Cisco VPN Services Port Adapter (VSPA), the RSA key modulusmust be a minimum of 384 bits and must be a multiple of 64.

Specifying a Storage Location for RSA Keys

When you issue the crypto key generate rsa commandwith the storage devicename : keyword and argument, the RSA keys will bestored on the specified device. This location will supersede anycrypto key storage commandsettings.

Specifying a Device for RSA Key Generation

As of Cisco IOS Release 12.4(11)T and later releases, you mayspecify the device where RSA keys are generated. Devices supportedinclude NVRAM, local disks, and USB tokens. If your router has aUSB token configured and available, the USB token can be used ascryptographic device in addition to a storage device. Using a USBtoken as a cryptographic device allows RSA operations such as keygeneration, signing, and authentication of credentials to beperformed on the token. The private key never leaves the USB tokenand is not exportable. The public key is exportable.

RSA keys may be generated on a configured and available USBtoken, by the use of the on devicename : keyword and argument. Keys that reside on aUSB token are saved to persistent token storage when they aregenerated. The number of keys that can be generated on a USB tokenis limited by the space available. If you attempt to generate keyson a USB token and it is full you will receive the followingmessage:

% Error in generating keys:no available resources 

Key deletion will remove the keys stored on the token frompersistent storage immediately. (Keys that do not reside on a tokenare saved to or deleted from nontoken storage locations when thecopyor similarcommand is issued.)

For information on configuring a USB token, see “ Storing PKICredentials ” chapter in the Cisco IOS Security ConfigurationGuide, Release 12.4T. For information on using on-token RSAcredentials, see the “ Configuring and Managing a Cisco IOSCertificate Server for PKI Deployment ” chapter in the Cisco IOSSecurity Configuration Guide , Release 12.4T.

Specifying RSA Key Redundancy Generation on aDevice

You can specify redundancy for existing keys only if they areexportable.

Examples

The following example generates a general-usage 1024-bit RSA keypair on a USB token with the label “ms2” with crypto enginedebugging messages shown:

Router(config)# crypto key generate rsa label ms2 modulus 2048 on usbtoken0:The name for the keys will be: ms2 % The key modulus size is 2048 bits % Generating 1024 bit RSA keys, keys will be on-token, non-exportable... Jan 7 02:41:40.895: crypto_engine: Generate public/private keypair [OK] Jan 7 02:44:09.623: crypto_engine: Create signature Jan 7 02:44:10.467: crypto_engine: Verify signature Jan 7 02:44:10.467: CryptoEngine0: CRYPTO_ISA_RSA_CREATE_PUBKEY(hw)(ipsec) Jan 7 02:44:10.467: CryptoEngine0: CRYPTO_ISA_RSA_PUB_DECRYPT(hw)(ipsec) 

Now, the on-token keys labeled “ms2” may be used forenrollment.

The following example generates special-usage RSA keys:

Router(config)# crypto key generate rsa usage-keysThe name for the keys will be: myrouter.example.comChoose the size of the key modulus in the range of 360 to 2048 for your Signature Keys. Choosing a key modulus greater than 512 may take a few minutes.How many bits in the modulus[512]? <return>Generating RSA keys.... [OK].Choose the size of the key modulus in the range of 360 to 2048 for your Encryption Keys. Choosing a key modulus greater than 512 may take a few minutes.How many bits in the modulus[512]? <return>Generating RSA keys.... [OK].

The following example generates general-purpose RSA keys:

Cisco Content Hub - crypto key generate rsa (6)
Note

You cannot generate both special-usage and general-purpose keys;you can generate only one or the other.

Router(config)# crypto key generate rsa general-keysThe name for the keys will be: myrouter.example.comChoose the size of the key modulus in the range of 360 to 2048 for your General Purpose Keys. Choosing a key modulus greater than 512 may take a few minutes.How many bits in the modulus[512]? <return>Generating RSA keys.... [OK].

The following example generates the general-purpose RSA key pair“exampleCAkeys”:

crypto key generate rsa general-keys label exampleCAkeyscrypto ca trustpoint exampleCAkeys enroll url http://exampleCAkeys/certsrv/mscep/mscep.dll rsakeypair exampleCAkeys 1024 1024

The following example specifies the RSA key storage location of“usbtoken0:” for “tokenkey1”:

crypto key generate rsa general-keys label tokenkey1 storageusbtoken0:

The following example specifies the redundancy keyword:

Router(config)# crypto key generate rsa label MYKEYS redundancy

The name for the keys will be: MYKEYS

Choose the size of the key modulus in the range of 360 to 2048for your

General Purpose Keys. Choosing a key modulus greater than 512may take

a few minutes.

How many bits in the modulus [512]:

% Generating 512 bit RSA keys, keys will be non-exportable withredundancy...[OK]

Related Commands

Command

Description

copy

Copies any file from a source to a destination, use the copycommand in privileged EXEC mode.

crypto key storage

Sets the default storage location for RSA key pairs.

debug crypto engine

Displays debug messages about crypto engines.

hostname

Specifies or modifies the hostname for the network server.

ip domain-name

Defines a default domain name to complete unqualified hostnames(names without a dotted-decimal domain name).

show crypto key mypubkey rsa

Displays the RSA public keys of your router.

show crypto pki certificates

Displays information about your PKI certificate, certificationauthority, and any registration authority certificates.

Cisco Content Hub - crypto key generate rsa (2024)

FAQs

How to generate RSA key command? ›

Generate RSA Keys
  1. Open a shell using Putty or another utility.
  2. Use commands to generate an RSA key file. Type the following command to generate RSA keys: ssh-keygen -t rsa. ...
  3. Navigate to the. rsakey. folder that you created in step 2b. ...
  4. Locate the public key beginning with. ssh. and copy the key.

How to generate RSA in Cisco? ›

Generate the RSA Keys

By default, RSA key pairs do not exist on the Cisco router. You need to add the optional command usage-keys to the command to generate an encryption key pair and an authentication key pair. The command for generating RSA key pairs is crypto key generate rsa usage-keys.

What does crypto key generate RSA command mean? ›

Syntax: crypto key { generate | zeroize } rsa [ modulus modulus-size ] The generate keyword places an RSA host key pair in the flash memory and enables SSH on the device, if it is not already enabled. The optional [modulus modulus-size ] parameter specifies the modulus size of the RSA key pair, in bits.

Which RSA key should be generated with 1024 modulus bits? ›

By default, the modulus of a certification authority (CA) key is 1024 bits. The recommended modulus for a CA key is 2048 bits. The range of a CA key modulus is from 350 to 4096 bits.

How to generate RSA private key from certificate? ›

Right-click the openssl.exe file and select Run as administrator. Enter the following command to begin generating a certificate and private key: req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -keyout privateKey. key -out certificate.

How to generate RSA key from PuTTY? ›

Generating an SSH key pair using PuTTY
  1. Start PuTTYgen by clicking Start > Programs > PuTTY > PuTTYgen. ...
  2. Click SSH-2 RSA as the type of key to generate. ...
  3. Click Generate and then move the cursor around the blank area of the Key section to generate the random characters that create a unique key.

How to generate RSA key pair in terminal? ›

In a terminal, type the command ssh-keygen -t rsa, and press enter. To save the key pair in other than the default directory of ~./ssh or with a different name, add the -f flag followed by the directory and key pair name (e.g. ~/Desktop/key).

How to create a SSH RSA key pair? ›

Generate an SSH Key Pair
  1. Run the ssh-keygen command. You can use the -t option to specify the type of key to create. ...
  2. The command prompts you to enter the path to the file in which you want to save the key. ...
  3. The command prompts you to enter a passphrase. ...
  4. When prompted, enter the passphrase again to confirm it.

How do I find my RSA host key? ›

Finding the host key fingerprint
  1. Find the SSH server configuration file available at /etc/ssh/sshd_config.
  2. Find the SSH protocol used. ...
  3. Find the HostKey property configured in the SSH server configuration file based on the protocol configured in the preceding step. ...
  4. Use the following command: ...
  5. Select the RSA key file.
Jan 27, 2017

How are crypto keys generated? ›

Encryption keys can be generated by the encryption key server, by applications such as Tivoli Storage Manager, or by a utility such as keytool.

What is the default key for RSA? ›

The default Key Name is id_rsa . Keys are generated in /root/. ssh/ so the default key name would create a private key in /root/. ssh/id_rsa , and a public key in /root/.

Which is better 1024 bit or 2048-bit RSA? ›

Referencing the table linked above, a 1024-bit key has approximately 80 bits of strength, while a 2048-bit key has approximately 112 bits. Thus, it takes approximately 2112/280 = 232 times as long to factor a 2048-bit key. In other words, it takes around four billion times longer to factor a 2048-bit key.

What is the difference between 1024 and 2048 key? ›

While doubling key strength delivers an exponential increase in protection -- encryption strength is directly tied to key size -- the computational power required to process 2,048-bit certificates is five to 30 times greater than that for 1,024-bit certificates.

What is the difference between 1024 and 2048 SSH key? ›

There are no performance differences between 1024 and 2048 key. Generate RSA keys. You can use the RSA keys for SSH protocol 1 and 2 versions. DSA keys for use only SSH protocol version 2.

How long does it take to generate RSA private key? ›

To generate a key pair, select the bit length of your key pair and click Generate key pair. Depending on length, your browser may take a long time to generate the key pair. A 1024-bit key will usually be ready instantly, while a 4096-bit key may take up to several minutes.

Is RSA private key same as private key? ›

RSA key is a private key based on RSA algorithm. Private Key is used for authentication and a symmetric key exchange during establishment of an SSL/TLS session. It is a part of the public key infrastructure that is generally used in case of SSL certificates.

How do I get my RSA private key from public key? ›

No, there is no known efficient method to find an RSA private key from public key, ciphertext and plaintext, including when no padding is used and e=3. The best known method is factoring the public modulus, which then trivially allows to find a working private key.

How to generate RSA key PEM? ›

Generate SSH Keys in PEM Format to Connect to a Public or On-Premises sFTP Server
  1. Verify the key by opening the file in Notepad. The key must start with the following phrase. ...
  2. Use -m PEM with ssh-keygen to generate private keys in PEM format: Copy ssh-keygen -t rsa -m PEM.

Is it possible to use ssh-keygen to create an SSH key without a password? ›

Using ssh-copy-id, you can upload a public key to a remote server and connect without a password. However, you should not enable passwordless authentication for all systems. Instead, use it to access systems you use frequently.

Where does PuTTY store RSA keys? ›

Like other SSH implementations, PuTTY records the host keys of SSH servers it encounters. They are stored in the Windows registry under the key \HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\SshHostKeys .

How do I generate a RSA 2048 key pair? ›

  1. Generate an RSA keypair with a 2048 bit private keyEdit. Execute command: "openssl genpkey -algorithm RSA -out private_key.pem -pkeyopt rsa_keygen_bits:2048" (previously “openssl genrsa -out private_key.pem 2048”) ...
  2. Extracting the public key from an RSA keypairEdit. ...
  3. Viewing the key elementsEdit.

How to generate 2048 RSA key in Linux? ›

Generate an SSH Key Pair on Windows Using the PuTTYgen Program
  1. Run the PuTTYgen program. ...
  2. Set the Type of key to generate option to SSH-2 RSA.
  3. In the Number of bits in a generated key box, enter 2048.
  4. Click Generate to generate a public/private key pair.

How to generate SSH key RSA with email? ›

Generating a new SSH key
  1. Open Terminal .
  2. Paste the text below, substituting in your GitHub email address. ssh-keygen -t ed25519 -C "your_email@example.com" Note: If you are using a legacy system that doesn't support the Ed25519 algorithm, use: ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

How do I create a certificate key pair? ›

  1. Steps to generate a key and CSR.
  2. Configure a certificate for multiple domain names.
  3. Set the OpenSSL configuration environment variable (optional)
  4. Generate a key.
  5. Create a certificate signing request to send to a certificate authority.
  6. Send the CSR to a certificate authority to obtain an SSL certificate.

What is the RSA key pair? ›

An RSA key pair includes a private and a public key. The RSA private key is used to generate digital signatures, and the RSA public key is used to verify digital signatures. The RSA public key is also used for key encryption of DES or AES DATA keys and the RSA private key for key recovery.

How to generate RSA private key on server? ›

In Windows:
  1. Open the Command Prompt (Start > Programs > Accessories > Command Prompt).
  2. Navigate to the following folder: C:\Program Files\ListManager\tclweb\bin\certs.
  3. Type the following: openssl genrsa -out rsa.private 1024.
  4. Press ENTER. The private key is generated and saved in a file named "rsa.

How do I enable RSA authentication? ›

On one device (for example, your computer), do the following:
  1. Go to RSA SecurID Access My Page.
  2. Enter your email address.
  3. Enter your RSA SecurID passcode or password, depending on what you configured.
  4. Complete any additional authentication that you are prompted for.
  5. Click RSA SecurID Authenticate app >Get Started.

How do I claim my host key? ›

Android | iOS
  1. Join a meeting.
  2. Tap More in the meeting controls.
  3. Tap Enter Host Key to Claim Host.
  4. Enter your host key.
  5. Tap Claim. Once the host key is verified, you will have host controls in the meeting.
May 2, 2023

How to generate RSA key on Linux? ›

Linux and MacOS X
  1. Open a terminal window. At the shell prompt, type the following command: ssh-keygen -t rsa.
  2. The ssh-keygen program will prompt you for the location of the key file. ...
  3. Note the location to which your public and private key were saved; they will be required in a subsequent step.

How to generate RSA key in PowerShell? ›

Generate SSH Keys in Windows with PowerShell
  1. Open the Start menu and type PowerShell.
  2. Select PowerShell and click the Run as Administrator option.
  3. Generate an SSH key pair: ...
  4. Press Enter again when you see a prompt to “Enter file in which to save the key”.
  5. When prompted, type a secure passphrase, and press Enter .
Jan 31, 2023

How to generate RSA key in Git Bash? ›

If you don't have keys yet, you can generate them on your side using the Git Bash app.
  1. Open Git Bash and run the following: $ ssh-keygen -t rsa -b 4096 -C "your_email@example.com" ...
  2. When you're prompted to “Enter a file in which to save the key”, press Enter.

Top Articles
Latest Posts
Article information

Author: Velia Krajcik

Last Updated:

Views: 6372

Rating: 4.3 / 5 (54 voted)

Reviews: 85% of readers found this page helpful

Author information

Name: Velia Krajcik

Birthday: 1996-07-27

Address: 520 Balistreri Mount, South Armand, OR 60528

Phone: +466880739437

Job: Future Retail Associate

Hobby: Polo, Scouting, Worldbuilding, Cosplaying, Photography, Rowing, Nordic skating

Introduction: My name is Velia Krajcik, I am a handsome, clean, lucky, gleaming, magnificent, proud, glorious person who loves writing and wants to share my knowledge and understanding with you.