To secure user EXEC mode access, enter line console configuration mode using the line console 0
global configuration command. Specify the user EXEC mode password using the password password
command. Finally, enable user EXEC access using the login
command.
To secure privileged EXEC access, use the enable secret password
global config command, as shown in the example.
The startup-config and running-config files display most passwords in plaintext. To encrypt all plaintext passwords, use the service password-encryption
global config command.
MD5 hashes are no longer considered secure because attackers can reconstruct valid certificates. The enable secret password
command shown in the figure uses an MD5 hash by default. Therefore, it is now recommended that you configure all secret passwords using either type 8 or type 9 passwords. Type 8 and type 9 were introduced in Cisco IOS 15.3(3)M.
To set an encrypted password, use the enable algorithm-type command syntax:
The options for the command are described below:
Algorithm Keyword | Description |
---|---|
md5 |
Type 5; selects the message digest algorithm 5 (MD5) as the hashing algorithm. |
scrypt |
Type 9; selects scrypt as the hashing algorithm. [best option] |
sha256 |
Type 8; selects Password-Based Key Derivation Function 2 (PBKDF2) with Secure Hash Algorithm, 256-bits (SHA-256) as the hashing algorithm. |
secret |
stores the password in plaintext |
Type 8 and type 9 encryption was also introduced in Cisco IOS 15.3(3)M for the username secret
command:
These login enhancements can only be enabled if the local database is used for authentication for local and remote access. If the lines are configured for password authentication only, then the enhanced login features are not enabled.
All login enhancement features are disabled until the login block-for
command is configured.
The login enhancement configuration commands are described below:
Command | Importance |
---|---|
login block-for |
Can defend against DoS attacks by disabling logins after a specified number of failed login attempts. When implemented, a one-second delay between login attempts is automatically invoked. |
login quiet-mode |
Maps to an ACL that identifies the permitted hosts. This ensures that only authorized hosts can attempt to login to the router. Reset using the login normal-mode command. |
login delay |
Specifies a number of seconds the user must wait between unsuccessful login attempts. Defaults to one second. |
login on-[success|failure] |
Log successful and unsuccessful login attempts. The number of login attempts before a logging message is generated can be specified by appending every attempts to the command, where the default attempts value is 1 attempt. The valid range is from 1 to 65,535. |
These login configuration commands do not apply to console connections. When dealing with console connections, it is assumed that only authorized personnel have physical access to the devices.
As an alternative to the login on-failure log
command, the security authentication failure rate
command can be configured to generate a log message when the login failure rate is exceeded.
A Cisco router can connect via SSH to another SSH-enabled router using the ssh -l username ip-address
command:
There are 16 privilege levels in total, as listed below. Commands that are available at lower privilege levels are also executable at higher levels.
disable
, enable
, exit
, help
, and logout
.enable
(privileged EXEC) mode privileges (enable
command). Users can change configurations and view configuration files.To assign commands to a custom privilege level, use the privilege
global configuration mode:
The use of privilege levels has its limitations:
show ip route
allows the user access to all show
and show ip
commands.There are two methods to create passwords for the various privilege levels:
Both the username secret and the enable secret commands are configured for type 9 encryption.
This feature provides granular access to the OS by controlling which commands are available to specific roles. Each view defines the CLI commands that each user can access. Additionally, administrators can control user access to specific ports, logical interfaces, and slots on a router.
Role-based CLI provides three types of views that dictate which commands are available:
Before an administrator can create a view, AAA must be enabled using the aaa new-model
command. To configure and edit views, an administrator must log in as the root view using the enable view [root]
command. When prompted, enter the enable secret
password.
Excluding the root view, there is a maximum limit of 15 views.
There are three steps to create and manage a specific view:
parser view view-name
global configuration command.secret password
view configuration command. The password must be created immediately after creating a view, otherwise, an error message will appear.
commands parser-mode
command.The options for the command are described below:
Parameter | Description |
---|---|
parser-mode |
The mode in which the specified command exists; for example, EXEC mode. |
include |
Adds a command or an interface to the view and allows the same command or interface to be added to other views. |
include-exclusive |
Adds a command or an interface to the view and excludes the same command or interface from being added to all other views. |
exclude |
Excludes a command or an interface from the view. |
all |
A "wildcard" that allows every command in a specified configuration mode that begins with the same keyword or every subinterface for a specified interface to be part of the view. |
interface interface-name command |
Interface that is added to the view. Command that is added to the view. |
There are three steps to create and manage a superview:
parser view view-name superview
global configuration command.secret password
view configuration command. The password must be created immediately after creating the superview, otherwise, an error message will appear.
view view-name
command.To verify view configuration, use show parser view [all]
Cisco IOS Resilient Configuration features allow for faster recovery if someone maliciously or unintentionally reformats flash memory or erases the startup configuration file in NVRAM.
These features maintain a secure working copy of the device's IOS image file or the running configuration file. These secure files cannot be removed by the user and are referred to as the primary bootset.
IOS Image Resilience is only available on older routers that support a PCMCIA Advanced Technology Attachment (ATA) flash interface. Newer routers such as the ISR 4000 do not support this feature.
Cisco IOS file system prevents secured files from being listed in the output of the dir
command. Use the show secure bootset
command to verify the existence of a secured archive or IOS image.
To secure the IOS image and enable Cisco IOS image resilience, use the secure boot-image
global configuration mode command. When enabled for the first time, the running Cisco IOS image is secured and a log entry is generated.
Image Resilience can only be disabled through a console session using the no secure boot-image
global configuration command.
This command functions properly only when the system is configured to run an image from a flash drive with an ATA interface. Additionally, the running image must be loaded from persistent storage to be secured as primary.
Images that are loaded from a remote location, such as a TFTP server, cannot be secured.
To copy the running-configuration and securely archive it in persistent storage, use the secure boot-config
global configuration command. The configuration archive is hidden and cannot be viewed or removed directly from the CLI prompt.
Subsequent use of the secure boot-config
command will update the archived configuration to match the latest version.
The configuration file in the primary bootset is a copy of the running configuration that was in use when the feature was first enabled.
Secure Copy Protocol (SCP) is used to remotely backup Resilient Configuration files. SCP provides a secure and authenticated method for copying router configuration or router image files to a remote location.
SCP requires the SSH and AAA features to be enabled.
Use the following steps to configure a router or switch for server-side SCP with local AAA:
aaa authentication login default local
command to use the local database for authentication.aaa authorization exec default local
command to configure command authorization.ip scp server enable
command.To copy a file to a remote location using SCP, use the copy source scp:
command. A series of prompts will be presented in order to configure the destination of the SCP action:
The most common authentication issue is an incorrect username/password combination. There is also an authentication failure if the username/password combination was not assigned the privilege 15
configuration on the SCP server.
Enter the debug ip scp
command to watch the transfer proceed, if verification is needed.
To restore the primary bootset from a secure archive:
reload
command. If necessary, issue the break sequence to enter ROM monitor (ROMmon) mode.dir drive
command to list the contents of the storage device that contains the secure bootset file.boot filepath
command, pointing to the secure archive found in Step 2.secure boot-config restore filepath
command.copy source running-configuration
command (using the restored file from Step 3 as the source) to copy the rescued configuration file to the running configuration.If a router is compromised or needs to be recovered from a misconfigured password, an administrator must follow the password recovery procedure. Depending on the device, this procedure may vary.
Password Recovery Procedure
show version
command to display the configuration register setting and document the value (e.g., 0x2102`).reset
command.CTRL-C
to skip the initial setup procedure.copy startup-config running-config
command.config-register address
global configuration command.copy running-config startup-config
command. On the next reboot, the router will load the new startup configuration file that contains the changed password.For security reasons, password-recovery requires the administrator to have physical access to the router through a console cable.
If an attacker gains physical access to a router or switch, they could potentially gain control of the device through the password recovery procedure. This leaves the router configuration intact, making this type of attack difficult to detect.
Administrators can mitigate this potential risk by using the no service password-recovery
global configuration command. Once password-recovery is disabled, all access to ROMmon mode is disabled.
An attacker may use the password-recovery method to discover the device configuration and other pertinent information about the network, such as traffic flows and access control restrictions.
To recover a device after the password-recovery service is disabled, initiate the break sequence within five seconds after the image decompresses during the boot. You will be prompted to confirm the break key action. After confirmation, the startup configuration is completely erased, and the router boots with the factory default configuration. If you do not confirm the break action, the router boots normally with the password-recovery feature still disabled.