Comando Cisco crypto key generate rsa : Come Generare le Chiavi per SSH?

2 min di lettura
Pubblicato il 15 Novembre 2026
Intermedio security_access

Comando Cisco crypto key generate rsa : Come Generare le Chiavi per SSH?

Il comando crypto key generate rsa genera la coppia di chiavi RSA necessaria per abilitare SSH su Cisco IOS. Senza chiavi, ip ssh non funziona e l'accesso sicuro è impossibile.

{ } Sintassi
crypto key generate rsa
! Prerequisiti
hostname R1
ip domain-name lab.local

! Genera chiavi RSA 1024 o 2048 bit
crypto key generate rsa
! Oppure in una riga
crypto key generate rsa modulus 1024
crypto key generate rsa modulus 2048

! Verifica
show crypto key mypubkey rsa
show ip ssh
>_ Verifica - Output
Router - PuTTY
R1# configure terminal R1(config)# hostname R1 R1(config)# ip domain-name lab.local R1(config)# crypto key generate rsa The name for the keys will be: R1.lab.local Choose the size of the key modulus in the range of 360 to 4096 for your General Purpose Keys. Choosing a key modulus greater than 512 may take a few minutes.How many bits in the modulus [512]: 1024 % Generating 1024 bit RSA keys, keys will be non-exportable...[OK]R1(config)# ip ssh version 2 R1(config)# line vty 0 4 R1(config-line)# transport input ssh R1(config-line)# login localR1# show ip ssh SSH Enabled - version 2.0 Authentication methods:publickey,keyboard-interactive,password
! Errore Comune
⚠ hostname e ip domain-name mancanti - chiavi non generate

Se provi crypto key generate rsa senza aver impostato hostname diverso da Router e ip domain-name, IOS rifiuta: % Please define a hostname other than Router o % Please define a domain-name.

Fix: hostname R1 + ip domain-name lab.local + poi crypto key generate rsa modulus 1024. Per SSHv2 usa almeno 1024 bit, meglio 2048.

✦ Trasparenza AI: uso strumenti AI per bozze, schemi e immagini. Ogni contenuto lo revisiono, testo i comandi in laboratorio e lo riscrivo con la mia esperienza in classe prima di pubblicarlo. La responsabilità di quello che leggi è mia.
Mario Giagnotti
AUTORE
Mario Giagnotti
Ingegnere Elettronico e docente di Informatica.