Secure Shell

This section contains the following topics:

Information About Secure Shell

Secure Shell (SSH) is a protocol that provides a secure, remote connection to a device. SSH provides more security for remote connections than Telnet does by providing strong encryption when a device is authenticated. This software release supports SSH Version 1 (SSHv1) and SSH Version 2 (SSHv2).

Prerequisites for Configuring Secure Shell

The following are the prerequisites for configuring the device for secure shell (SSH):

  • For SSH to work, the switch needs an RSA public/private key pair.

  • The Secure Shell (SSH) server requires an IPsec (Data Encryption Standard [DES] or 3DES) encryption software image; the SSH client requires an IPsec (DES or 3DES) encryption software image.)

  • Configure a hostname and host domain for your device by using the hostname and ip domain-name commands in global configuration mode. Use the hostname and ip domain-name commands in global configuration mode.

Restrictions for Configuring Secure Shell

The following are restrictions for configuring the router for secure shell.

  • The router supports RSA authentication.

  • SSH supports only the execution-shell application.

  • The SSH server and the SSH client are supported only on Data Encryption Standard (DES) (56-bit) and 3DES (168-bit) data encryption software. In DES software images, DES is the only encryption algorithm available. In 3DES software images, both DES and 3DES encryption algorithms are available.


    Note


    Cisco highly recommends the 3DES encryption as it is stronger. See the Cisco IOS-XE Device hardening guide at https://www.cisco.com/c/en/us/support/docs/ip/access-lists/13608-21.html for details.
  • This software release supports IP Security (IPSec).

  • The router supports the Advanced Encryption Standard (AES) encryption algorithm with a 128-bit key, 192-bit key, or 256-bit key. However, symmetric cipher AES to encrypt the keys is not supported.

  • The login banner is not supported in Secure Shell Version 1. It is supported in Secure Shell Version 2, which Cisco recommends due to its better security.

  • The -l keyword and userid :{number} {ip-address} delimiter and arguments are mandatory when configuring the alternative method of Reverse SSH for console access.

SSH And Router Access

Secure Shell (SSH) is a protocol that provides a secure, remote connection to a device. SSH provides more security for remote connections than Telnet does by providing strong encryption when a device is authenticated. This software release supports SSH Version 1 (SSHv1) and SSH Version 2 (SSHv2). SSH functions the same in IPv6 as in IPv4. For IPv6, SSH supports IPv6 addresses and enables secure, encrypted connections with remote IPv6 nodes over an IPv6 transport.

SSH Servers, Integrated Clients, and Supported Versions

The Secure Shell (SSH) Integrated Client feature is an application that runs over the SSH protocol to provide device authentication and encryption. The SSH client enables a Cisco device to make a secure, encrypted connection to another Cisco device or to any other device running the SSH server. This connection provides functionality similar to that of an outbound Telnet connection except that the connection is encrypted. With authentication and encryption, the SSH client allows for secure communication over an unsecured network.

The SSH server and SSH integrated client are applications that run on the switch. The SSH server works with the SSH client supported in this release and with non-Cisco SSH clients. The SSH client works with publicly and commercially available SSH servers. The SSH client supports the ciphers of Data Encryption Standard (DES), 3DES, and password authentication.


Note


The SSH client functionality is available only when the SSH server is enabled.

User authentication is performed like that in the Telnet session to the device. SSH also supports the following user authentication methods:

  • TACACS+

  • RADIUS

  • Local authentication and authorization

SSH Configuration Guidelines

Follow these guidelines when configuring the device as an SSH server or SSH client:

  • An RSA key pair generated by a SSHv1 server can be used by an SSHv2 server, and the reverse.

  • If you get CLI error messages after entering the crypto key generate rsa global configuration command, an RSA key pair has not been generated. Reconfigure the hostname and domain, and then enter the crypto key generate rsa command.

  • When generating the RSA key pair, the message No hostname specified might appear. If it does, you must configure an IP hostname by using the hostname global configuration command.

  • When generating the RSA key pair, the message No domain specified might appear. If it does, you must configure an IP domain name by using the ip domain-name global configuration command.

  • When configuring the local authentication and authorization authentication method, make sure that AAA is disabled on the console.

How to Configure Secure Shell

This section contains the following:

Set up the router to run SSH

To set up your device to run SSH.

Before you begin

Ensure to configure user authentication for local or remote access.

Procedure


Step 1

Enter the privileged EXEC mode.

Example:

router> enable

Step 2

Enter the global configuration mode.

Example:

router# configure terminal

Step 3

Configure a hostname and domain name for the device.

Example:

router(config)# hostname <your_hostname>
router(config)# ip domain-name <your_domain_name>

Step 4

Generate an RSA key pair to enable SSH.

Use a modulus size of at least 1024 bits for security.

Example:

router(config)# crypto key generate rsa

Step 5

Exit the global configuration mode.

Example:

router(config)# end

Step 6

Verify the configuration.

Example:

router# show running-config

Step 7

(Optional) Save the configuration.

Example:

router# copy running-config startup-config

Configuring the SSH Server

Follow these steps to configure the SSH server:


Note


This procedure is only required if you are configuring the device as an SSH server.

SUMMARY STEPS

  1. enable
  2. configure terminal
  3. ip ssh version [2]
  4. ip ssh {timeout seconds | authentication-retries number}
  5. Use one or both of the following:
    • line vty line_number [ending line number]
    • transport input ssh
  6. end
  7. show running-config
  8. copy running-config startup-config

DETAILED STEPS

  Command or Action Purpose

Step 1

enable

Example:


router> enable

Enables privileged EXEC mode.

  • Enter your password if prompted.

Step 2

configure terminal

Example:


router# configure terminal

Enters global configuration mode.

Step 3

ip ssh version [2]

Example:


router(config)# ip ssh version 2

(Optional) Configures the device to run SSH Version 2.

If you do not enter this command or do not specify a keyword, the SSH server selects the latest SSH version supported by the SSH client. For example, if the SSH client supports SSHv1 and SSHv2, the SSH server selects SSHv2.

Step 4

ip ssh {timeout seconds | authentication-retries number}

Example:


router(config)# ip ssh timeout 90 
ip ssh authentication-retries 2

Configures the SSH control parameters:

  • Specify the time-out value in seconds; the default is 120 seconds. The range is 0 to 120 seconds. This parameter applies to the SSH negotiation phase. After the connection is established, the device uses the default time-out values of the CLI-based sessions.

    By default, up to five simultaneous, encrypted SSH connections for multiple CLI-based sessions over the network are available (session 0 to session 4). After the execution shell starts, the CLI-based session time-out value returns to the default of 10 minutes.

  • Specify the number of times that a client can re-authenticate to the server. The default is 3; the range is 0 to 5.

Repeat this step when configuring both parameters.

Step 5

Use one or both of the following:

  • line vty line_number [ending line number]
  • transport input ssh

Example:

router(config)# line vty 1 10

or

router(config-line)# transport input ssh

(Optional) Configures the virtual terminal line settings.

  • Enters line configuration mode to configure the virtual terminal line settings. For the line_number and ending_line_number arguments, the range is from 0 to 15.

  • Specifies that the device prevents non-SSH Telnet connections, limiting the device to only SSH connections.

Step 6

end

Example:


router(config-line)# end

Exits line configuration mode and returns to privileged EXEC mode.

Step 7

show running-config

Example:


router# show running-config 

Verifies your entries.

Step 8

copy running-config startup-config

Example:


router# copy running-config startup-config 

(Optional) Saves your entries in the configuration file.

Monitoring the SSH Configuration and Status

Table 1. Commands for Displaying the SSH Server Configuration and Status

Command

Purpose

show ip ssh

Shows the version and configuration information for the SSH server.

show ssh

Shows the status of the SSH server.

Configuring the Router for Local Authentication and Authorization

You can configure AAA to operate without a server by setting the switch to implement AAA in local mode. The router then handles authentication and authorization. No accounting is available in this configuration.

Follow these steps to configure AAA to operate without a server by setting the router to implement AAA in local mode:


Note


To secure the router for HTTP access by using AAA methods, you must configure the router with the ip http authentication aaa global configuration command. Configuring AAA authentication does not secure the router for HTTP access by using AAA methods.

SUMMARY STEPS

  1. enable
  2. configure terminal
  3. aaa new-model
  4. aaa authentication login default local
  5. aaa authorization exec local
  6. aaa authorization network local
  7. username name privilege level password encryption-type password
  8. end
  9. show running-config
  10. copy running-config startup-config

DETAILED STEPS

  Command or Action Purpose

Step 1

enable

Example:


router> enable

Enables privileged EXEC mode.

  • Enter your password if prompted.

Step 2

configure terminal

Example:


router# configure terminal

Enters global configuration mode.

Step 3

aaa new-model

Example:


router(config)# aaa new-model

Enables AAA

Step 4

aaa authentication login default local

Example:


router(config)# aaa authentication login default local

Sets the login authentication to use the local username database. The default keyword applies the local user database authentication to all ports.

Step 5

aaa authorization exec local

Example:


router(config-line)# aaa authorization exec local 

Configures user AAA authorization, check the local database, and allow the user to run an EXEC shell.

Step 6

aaa authorization network local

Example:


router(config-line)# aaa authorization network local

Configures user AAA authorization for all network-related service requests.

Step 7

username name privilege level password encryption-type password

Example:


router(config-line)# username your_user_name privilege 1 password 7 secret567

Enters the local database, and establishes a username-based authentication system.

Repeat this command for each user.

  1. For name, specify the user ID as one word. Spaces and quotation marks are not allowed.

  2. (Optional) For level, specify the privilege level the user has after gaining access. The range is 0 to 15. Level 15 gives privileged EXEC mode access. Level 0 gives user EXEC mode access.

  3. For encryption-type, enter 0 to specify that an unencrypted password follows. Enter 7 to specify that a hidden password follows.

  4. For password, specify the password the user must enter to gain access to the switch. The password must be from 1 to 25 characters, can contain embedded spaces, and must be the last option specified in the username command.

Step 8

end

Example:


router(config-line)# end

Exits line configuration mode and returns to privileged EXEC mode.

Step 9

show running-config

Example:


router# show running-config 

Verifies your entries.

Step 10

copy running-config startup-config

Example:


router# copy running-config startup-config 

(Optional) Saves your entries in the configuration file.

Information about Secure Copy

The Secure Copy Protocol (SCP) feature provides a secure and authenticated method for copying router configuration or router image files. SCP relies on Secure Shell (SSH), an application and a protocol that provide a secure replacement for the Berkeley r-tools.

Prerequisites for Secure Copy

The following are the prerequisites for configuring the device for secure shell (SSH):

  • Before enabling SCP, you must correctly configure SSH, authentication, and authorization on the switch.

  • Because SCP relies on SSH for its secure transport, the router must have an RSA key pair.

  • SCP relies on SSH for security.

  • SCP requires that authentication, authorization, and accounting (AAA) authorization be configured so the router can determine whether the user has the correct privilege level.

  • A user must have appropriate authorization to use SCP.

  • A user who has appropriate authorization can use SCP to copy any file in the Cisco IOS File System (IFS) to and from a switch by using the copy command. An authorized administrator can also do this from a workstation.

Restrictions for Configuring Secure Copy

  • Before enabling SCP, you must correctly configure SSH, authentication, and authorization on the router.

  • When using SCP, you cannot enter the password into the copy command. You must enter the password when prompted.

Configuring Secure Copy

To configure the Cisco router for Secure Copy (SCP) server-side functionality, perform the following steps.

SUMMARY STEPS

  1. enable
  2. configure terminal
  3. aaa new-model
  4. aaa authentication login {default | list-name} method1 [ method2... ]
  5. username name [privilege level ] password encryption-type encrypted-password
  6. ip scp server enable
  7. exit
  8. show running-config
  9. debug ip scp

DETAILED STEPS

  Command or Action Purpose

Step 1

enable

Example:

router> enable

Enables privileged EXEC mode.

  • Enter your password if prompted.

Step 2

configure terminal

Example:


router# configure terminal

Enters global configuration mode.

Step 3

aaa new-model

Example:


router(config)# aaa new-model

Sets AAA authentication at login.

Step 4

aaa authentication login {default | list-name} method1 [ method2... ]

Example:


router(config)# aaa authentication login default group tacacs+

Enables the AAA access control system.

Step 5

username name [privilege level ] password encryption-type encrypted-password

Example:


router(config)# username superuser privilege 2 password 0 superpassword

Establishes a username-based authentication system.

Note

 
You may omit this step if a network-based authentication mechanism, such as TACACS+ or RADIUS, has been configured.

Step 6

ip scp server enable

Example:


router(config)# ip scp server enable

Enables SCP server-side functionality.

Step 7

exit

Example:


router(config)# exit

Exits global configuration mode and returns to privileged EXEC mode.

Step 8

show running-config

Example:


router# show running-config

(Optional) Displays the SCP server-side functionality.

Step 9

debug ip scp

Example:


router# debug ip scp

(Optional) Troubleshoots SCP authentication problems.

Example

router# copy scp <somefile> your_username@remotehost:/<some/remote/directory>

SSH rekeying

SSH rekeying is a security feature that

  • replaces the encryption and integrity keys during an active SSH session,

  • initiates a new key exchange based on a configured time or data threshold, and

  • helps reduce the risk of long-term key exposure.

SSH rekeying can be initiated by either the SSH client or server. During rekeying, data transfer halts until the key exchange completes. The encryption algorithm negotiated at session startup remains in use during rekeying. OpenSSH-based clients version 7.5 or later support SSH rekey exchange.

Examples:

  • Rekeying every hour to ensure session security over long connections.

  • Rekeying after 1 GB of data transfer to limit the data encrypted with a single key.

    .

SSH rekeying types

You can configure SSH rekeying on Cisco routers in the following ways:

  • Time-based rekeying: Specify the interval (in minutes or seconds) after which rekeying occurs.

  • Volume-based rekeying: Specify the data volume (in KB or MB) that triggers rekeying.

Default values: If you do not configure these settings, the default values are typically 1 hour for time-based rekeying and 1 GB for volume-based rekeying.

Rekeying by time

Rekeying by time initiates a key exchange after a specific time interval.

  • In Common Criteria mode, the maximum allowed time is less than 60 minutes (3600 seconds).

  • The configurable range is 900–3600 seconds (15–60 minutes).

  • For some devices, the command accepts values in minutes, with a default of 60 minutes.

Rekeying by volume

Rekeying by volume enforces a new key exchange when the transmitted data reaches a configured threshold.

  • In Common Criteria mode, the maximum rekey volume is 1024 MB (1 GB).

  • The configurable range for the rekey volume is 50 MB to 1024 MB.

  • For some devices, the command accepts values in kilobytes, with a default of 1 GB.

Prerequisites

To configure SSH rekeying on Cisco routers, ensure these prerequisites are met.

  • The device runs Cisco IOS with SSH enabled.

  • SSH version 2 is recommended.

  • Administrative privilege access is required.

Best practices for SSH rekeying configuration are:

  • Enable SSH rekeying to reduce the risk from potential key compromise, especially in high-security environments.

  • Ensure rekey intervals comply with security policies, such as Common Criteria, by setting appropriate time or volume thresholds.

SSH session idle timeout settings

SSH sessions can be configured to disconnect after a period of inactivity.

  • Console timeout: console timeout <0-240> (in minutes; 0 means never timeout)

  • SSH idle timeout: ip ssh idle-time <0-240> (in minutes; 0 means never timeout)

Restrictions

The following limitations apply to SSH rekeying on Cisco routers:

  • During SCP downloads, the device acting as receiver cannot control the sender's data volume, so rekey is triggered only after the configured volume is received.

  • Large SSH bulk mode settings (for example, 1 GB) can lead to fewer rekeys than expected due to larger data windows.

  • The actual number of rekeys during SCP downloads may not match calculated expectations.

    This behavior is by design and aligns with current SSH implementation.

    Example observation:

    Transferring a 631.3 MB file with a 100 KB rekey threshold could yield an expected 6,463 rekeys, but only 689 may occur.

    This discrepancy is documented and not considered a defect.

  • SSH sessions established without rekey configuration do not support rekeying

  • When rekey is enabled, existing sessions will only adopt rekeying after the next exchange initiated from the other side.

  • Removing the rekey configuration disables SSH rekey for existing sessions.

  • Changing the rekey configuration does not affect active sessions until the subsequent rekey exchange.

  • When a rekey exchange occurs, the related data and time parameters for the session reset to the new configured value.

  • Do not modify the encryption method during rekeying.

Configure SSH rekeying

Configure SSH rekeying on Cisco IOS-XE devices to enhance session security by periodically renewing encryption keys.

Procedure


Step 1

Enable SSH and set the domain name.

Enter configuration mode.

Use the ip domain-name <example.com> command to set the domain name.

Use crypto key generate rsa modulus 2048 command to generate the RSA keys.

Use the ip ssh version 2 command to set the SSH version 2.

Step 2

Use the ip ssh rekey time <minutes> command configure time-based rekey.

Example:

Router#ip ssh rekey time 120
exit

For IR1800 series: The valid range is <10-1440> minutes (default 60 mins).

Step 3

Use the ip ssh rekey volume <size in KB> command configure volume-based rekey.

Example:

Router#ip ssh rekey volume 10240
exit

Triggers rekey after 10,240 KB.

For IR1800 series: The valid range is <100-4194303> minutes (default 1 GB).

Step 4

Remove rekey settings to reset to default value (optional):

Enter configuration mode.

Use no ip ssh rekey time command.

or

Use no ip ssh rekey volume command.


SSH rekeying is enabled on the device, improving session security through periodic key renewal.

Verifying SSH rekey configuration

Verification ensures that SSH rekeying is correctly configured and operational on the device.

Use show ip ssh command to show configuration details.

Router#show ip ssh
SSH Enabled - version 2.0
Authentication methods:publickey,keyboard-interactive,password
Authentication Publickey Algorithms:ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519,x509v3-ecdsa-sha2-nistp256,x509v3-ecdsa-sha2-nistp384,x509v3-ecdsa-sha2-nistp521,rsa-sha2-256,rsa-sha2-512,x509v3-rsa2048-sha256
Hostkey Algorithms:ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,rsa-sha2-512,rsa-sha2-256
Encryption Algorithms:chacha20-poly1305@openssh.com,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-gcm,aes256-gcm,aes128-ctr,aes192-ctr,aes256-ctr
MAC Algorithms:hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha2-256,hmac-sha2-512
KEX Algorithms:curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512
Authentication timeout: 120 secs; Authentication retries: 3
Minimum expected Diffie Hellman key size : 2048 bits
IOS Keys in SECSH format(ssh-rsa, base64 encoded): TP-self-signed-1538213291
Modulus Size : 2048 bits
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCw/l05OHVk/3MAC30fIpLf6rphTETPZtnIdlYbZPCc
L+gLy+dxsxq8kYXZ5lTQq+lstB+PB868xDz/mkk9OfNFcEwa2SavoyHuDeqN58FMFmU4z9guwfe66dIk
sdt1qA086Wc45BUBYrE3R4uVC1gQdkuHyIZmN54c3lvSRuToaGNo3M10rRjIELOWOV1Qbcr8e0nrAAmf
Xznx2lDqO2QPdynLEpLWinLpnwEFEJtQ2DXRAZO+a1SqGvfTbLZ+EQ7SCI39X0xC5YVCFRjD3NF+6NpO
Q6wt0my/5xNXr1m5uabfOco96lAXbCD4w55JDuv0Eq3siefVAuXXtgGpDCVB                    
IOS Keys in SECSH format(ssh-ec, base64 encoded): NONE

SSH session configuration attributes

SSH session attributes and algorithms includes:

  • SSH version and enablement status

  • Supported authentication methods and algorithms (public key, keyboard-interactive, password)

  • Hostkey and encryption algorithms

  • MAC and key exchange algorithms

  • Authentication timeout and retry settings

  • Minimum expected Diffie Hellman key size

  • Current session keys (in SECSH format)

Use show run | inc ssh command to show configuration details.

IR1800#show run | inc ssh
ip ssh bulk-mode 13107245
ip ssh rekey volume 100
 transport input ssh
 transport input ssh
IR1800#show run | inc ssh
ip ssh bulk-mode 13107245
ip ssh rekey time 120
 transport input ssh
 transport input ssh

Use show ssh rekey command to monitor SSH rekey activity and current session information details.

Router#show ssh rekey
SSHv2 server sessions
Connection  TimeTillRekey  DataLeftTillRekey TimeRekeys  VolumeRekeys
0           0:00           98                0           0

%No SSHv2 client connections running.
Router#show ssh rekey
SSHv2 server sessions
Connection  TimeTillRekey  DataLeftTillRekey TimeRekeys  VolumeRekeys
0           0:00           99997             0           0

SSHv2 client sessions
Connection  TimeTillRekey  DataLeftTillRekey TimeRekeys  VolumeRekeys
1           0:00           0                 0           0

Additional References

The following sections provide references related to the SSH feature.

Related Topic

Document Title

Configuring Identity Control policies and Identity Service templates for Session Aware networking.

Session Aware Networking Configuration Guide, Cisco IOS XE Release 3SE: https://www.cisco.com/en/US/docs/ios-xml/ios/san/configuration/xe-3se/3850/san-xe-3se-3850-book.pdf

Configuring RADIUS, TACACS+, Secure Shell, 802.1X and AAA.

Secure Shell Configuration Guide, Cisco IOS XE Gibraltar 16.11.x: https://www.cisco.com/c/en/us/td/docs/switches/lan/catalyst9500/software/release/16-11/configuration_guide/sec/b_1611_sec_9500_cg/configuring_secure_shell__ssh_.html