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:

Setting Up the Router to Run SSH

Follow the procedure given below to set up your device to run SSH:

Before you begin

Configure user authentication for local or remote access. This step is required. For more information, see Related Topics below.

Procedure

  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

hostname hostname

Example:


router(config)# hostname your_hostname 

Configures a hostname and IP domain name for your device.

Note

 

Follow this procedure only if you are configuring the device as an SSH server.

Step 4

ip domain-name domain_name

Example:


router(config)# ip domain-name your_domain_name 

Configures a host domain for your device.

Step 5

crypto key generate rsa

Example:


router(config)# crypto key generate rsa

Enables the SSH server for local and remote authentication on the device and generates an RSA key pair. Generating an RSA key pair for the device automatically enables SSH.

We recommend that a minimum modulus size of 1024 bits.

When you generate RSA keys, you are prompted to enter a modulus length. A longer modulus length might be more secure, but it takes longer to generate and to use.

Note

 
Follow this procedure only if you are configuring the device as an SSH server.

Step 6

end

Example:


router(config)# end

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.

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.

Procedure

  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.

Procedure

  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.

Procedure

  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>

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