How to Generate an RSA Crypto Key on Cisco Devices: Step‑By‑Step

- RSA keys enable secure SSH, HTTPS, and certificate-based authentication on Cisco devices.
- Always set a hostname and domain name before generating RSA keys.
- Minimum key size is 2048 bits; 4096 bits offer stronger security for high-risk environments.
- Use SSH v2 exclusively and disable Telnet to improve security.
- Periodically rotate RSA keys to comply with security best practices.
- Troubleshoot errors like low entropy, missing domain name, or unsupported key sizes promptly.
- ASA and IOS XE devices follow similar commands but may offer additional options for modern cryptography.
Securing network infrastructure has never been more important. Whether you manage enterprise routers, switches, or firewalls, encryption is the backbone of safe communications. Cisco devices rely heavily on RSA keys to enable SSH login, digital certificates, and secure management protocols.
Without properly generated crypto keys, your network is exposed to password sniffing, unauthorized access, and man‑in‑the‑middle attacks.
This guide explains what RSA keys are, why Cisco uses them, and provides a complete step‑by‑step walkthrough on generating them on various Cisco platforms. Whether you are a beginner learning device hardening or a network administrator refreshing Cisco security fundamentals, this article covers everything in depth.
What Is an RSA Crypto Key and Why Does Cisco Use It?
RSA (Rivest–Shamir–Adleman) is one of the most widely used public‑key encryption systems in networking. Cisco devices rely on RSA keys to enable:
- SSH remote access
- HTTPS/SSL for web management
- Certificate signing requests (CSRs)
- VPN authentication
- Secure communication between devices
RSA uses a public/private key pair. Your device generates both keys locally, stores the private key securely, and uses the public key for client connections. Because RSA is asymmetric, compromise of the public key cannot reveal the private key, making it ideal for network security.
Cisco requires RSA keys to activate SSH version 2 (the recommended secure method of remote login). Without RSA keys, the device defaults to older, insecure protocols like Telnet.
Pre‑Generation Requirements on Cisco Devices
Before generating an RSA key, ensure the following prerequisites are met:
1. Set a Hostname
RSA keys embed the device hostname into the key label. Without a hostname, Cisco will not proceed.
Router(config)# hostname Branch-Router
2. Configure a Domain Name
Cisco IOS uses the hostname and domain name to form the device’s fully qualified domain name (FQDN), required for RSA key generation.
Branch-Router(config)# ip domain-name corp.local
3. Ensure You Are Using a Supported IOS Version
Most modern Cisco IOS, IOS XE, and Catalyst OS versions support RSA key generation, although older devices may have size limitations (e.g., max 2048 bits).
4. Make Sure the Device Has Sufficient Entropy
Slow key generation on older hardware often results from low entropy. In these cases, physical input (traffic load) can speed up the process.
Step‑By‑Step: How to Generate an RSA Key on Cisco Devices
Below is a detailed walkthrough using Cisco IOS syntax (used by routers and switches). The same commands generally apply to ASA firewalls and Catalyst platforms with minor variations.
Step 1: Enter Global Configuration Mode
Branch-Router# configure terminal.
Step 2: Set Your Device Hostname
If you haven’t already:
Branch-Router(config)# hostname Branch-Router
Step 3: Define a Domain Name
This is required for SSH key generation:
Branch-Router(config)# ip domain-name corp.local
Step 4: Generate the RSA Keys
Use the main command:
Branch-Router(config)# crypto key generate rsa
You will be prompted to select a key size, usually from:
- 1024 bits (minimum acceptable)
- 2048 bits (standard for modern deployments)
- 4096 bits (very secure, but increases CPU load)
Example:
How many bits in the modulus [512]: 2048
% Generating 2048-bit RSA keys, keys will be non-exportable...
Cisco then generates the key pair and stores it in its internal secure key storage.
Step 5: Confirm the Key Was Created
Use:
Branch-Router# show crypto key mypubkey rsa
You will see key labels, sizes, and export settings.
How to Enable SSH After RSA Key Generation
RSA keys enable the device to support SSH automatically, but SSH must be manually activated.
1. Enable SSH Version 2 (Recommended)
Branch-Router(config)# ip ssh version 2
2. Configure Local User Accounts
SSH requires local credentials or AAA servers:
Branch-Router(config)# username admin privilege 15 secret StrongPass123
3. Set VTY Lines to Accept SSH Only
Branch-Router(config)# line vty 0 4
Branch-Router(config-line)# transport input ssh
Branch-Router(config-line)# login local
Branch-Router(config-line)# exit
4. Verify SSH Status
Branch-Router# show ip ssh.
You should see:
SSH Enabled - version 2.0
Authentication timeout: 120 secs
SSH is now fully functional and secured with RSA keys.
How to Regenerate or Delete RSA Keys
Here's a breakdown on how to regenerate or delete RSA keys:
Delete Old Keys
Branch-Router(config)# crypto key zeroize rsa
Regenerate New Keys
Simply repeat:
crypto key generate rsa
Always delete old keys before generating new ones to avoid conflicts.
RSA Key Generation on Cisco ASA Firewalls
Cisco ASA uses similar commands but with slight differences.
Set Hostname and Domain
ASA(config)# hostname HQ-FW
ASA(config)# domain-name corp.local
Generate RSA Key
ASA(config)# crypto key generate rsa modulus 2048
Enable SSH
ASA(config)# ssh 192.168.1.0 255.255.255.0 inside
ASA(config)# ssh version 2
RSA Key Generation on Cisco IOS XE Devices
IOS XE uses the same syntax as IOS, but supports larger key sizes and enhanced cryptographic algorithms (ECDSA, Ed25519). If you want RSA specifically, use:
crypto key generate rsa general-keys modulus 2048
Troubleshooting RSA Key Generation
- “Please define a domain name first.”
Solution:
ip domain-name example.com
- “Key size not supported.”
Older hardware may only support 1024‑bit RSA keys.
- “Low on entropy.”
Generate network traffic or reload the device.
- “SSH not working after generating keys.”
Common fixes include:
- Ensure transport input SSH is applied to VTY lines.
- Verify local users exist.
- Confirm you are using SSH v2
Best Practices for Secure RSA Deployment
To maximize security on Cisco devices, always follow these guidelines:
- Use 2048‑bit Minimum: 1024‑bit RSA is considered weak. 4096‑bit RSA is secure but heavy on older CPUs.
- Enable SSH v2 Only: SSHv1 is outdated and vulnerable.
- Rotate Keys Periodically: Especially in environments with compliance requirements.
- Disable Telnet on all Interfaces: Telnet transmits credentials in plain text.
- Protect Private Keys: Never export or store them externally unless required.
Why RSA Keys Matter in Modern Cisco Security
In an era where network attacks are increasingly sophisticated, RSA cryptography remains fundamental to device hardening. Cisco’s architecture relies heavily on RSA for authentication, encrypted management traffic, and identity validation.
Generating RSA keys is the entry point to activating SSH, secure HTTPS access, and certificate‑based authentication.
Without RSA keys, your Cisco device operates in an insecure state, leaving it vulnerable to credential theft, reconnaissance, and unauthorized configuration changes.
FAQs
What is an RSA key on Cisco devices?
An RSA key is a public/private cryptographic key pair used to secure SSH, HTTPS, and VPN connections on Cisco devices.
Why do I need to generate an RSA key?
Without RSA keys, secure remote access (SSH) and encrypted management traffic cannot function on Cisco routers, switches, or firewalls.
What is the recommended key size?
Cisco recommends a minimum of 2048 bits for RSA keys; 4096 bits offer stronger security but may slow older devices.
Can I generate RSA keys on ASA firewalls and IOS XE devices?
Yes. ASA and IOS XE support RSA key generation with similar commands, though IOS XE allows larger keys and additional algorithms.
How do I troubleshoot RSA key generation issues?
Common issues include missing domain names, unsupported key sizes, low entropy, or misconfigured VTY lines. Correct these and retry.
References
- Cisco: Cisco Business Switches 250 Series CLI Guide
- Network Lessons: How to configure SSH on Cisco IOS
- NetworkJutsu: How to enable SSH on Cisco Routers and Switches

