Examples for password encryption
This example demonstrates how to create a primary key, enable the AES password encryption feature, and configure a Type-6
encrypted password for an application that uses TACACS+.
key config-key ascii
New Master Key:
Retype Master Key:
configure terminal
feature password encryption aes tam
show encryption service status
Encryption service is enabled.
Master Encryption Key is configured.
Type-6 encryption is being used.
feature tacacs+
tacacs-server key Cisco123
show running-config tacacs+
feature tacacs+
logging level tacacs 5
tacacs-server key 6 "JDYkqyIFWeBvzpljSfWmRZrmRSRE8syxKlOSjP9RCCkFinZbJI3GD5c6rckJR/Qju2PKLmOewbheAA=="
Configuration examples for "show encryption mkey info" command
This example shows the output of various options of the
show encryption mkey info [all | hash-prefix | last-updated | length | protection-type]
command:
-
all
switch#show encryption mkey info all
Master-Key ID : 1
-------------------------------- --------------------------------------------------
Type : Running (Active)
Key-Hash(first 16 chars) : SHA512: TNESx8lzL5C1fRpb
Protection-Type : Hardware
Length : 20
Last updated : 2024-11-03 16:35:26.074 IST
-------------------------------- --------------------------------------------------
-
hash-prefix
: The key-Hash is the first 16 characters of the base64 encoding of the SHA-512 digest of the primary key.
switch#show encryption mkey info hash-prefix
Master-Key ID : 1
-------------------------------- --------------------------------------------------
Key-Hash(first 16 chars) : SHA512: TNESx8lzL5C1fRpb
-------------------------------- --------------------------------------------------
-
last-updated
: The Last updated attribute provides the timestamp of the last modification.
switch#show encryption mkey info last-updated
Master-Key ID : 1
-------------------------------- --------------------------------------------------
Last updated : 2024-11-03 16:35:26.074 IST
-------------------------------- --------------------------------------------------
-
length
: The Length shows the length of the configured primary key.
switch#show encryption mkey info length
Master-Key ID : 1
-------------------------------- --------------------------------------------------
Length : 23
-------------------------------- --------------------------------------------------
-
protection-type
: The protection-type indicates how the primary key is secured. The primary key is protected either by Hardware (which uses TAM encryption service) or Software (which uses internal hashing).
Protection type - Hardware
switch(config)#feature password encryption aes tam
switch#show encryption mkey info all
Master-Key ID : 1
-------------------------------- --------------------------------------------------
Type : Running (Active)
Key-Hash(first 16 chars) : SHA512: TNESx8lzL5C1fRpb
Protection-Type : Hardware
Length : 20
Last updated : 2024-11-03 16:35:26.074 IST
-------------------------------- --------------------------------------------------
Protection type - Software
switch#key config ascii <master-key> <retype master-key>
switch#show encryption mkey info all
Master-Key ID : 1
-------------------------------- --------------------------------------------------
Type : Running (Active)
Key-Hash(first 16 chars) : SHA512: TNESx8lzL5C1fRpb
Protection-Type : Software
Length : 20
Last updated : 2024-11-03 16:35:26.074 IST
-------------------------------- --------------------------------------------------
All attributes except Type and Protection-Type remain unchanged for a primary key. The use cases in this section describe how Type and Protection-Type fields change when you perform operations such as 'copy run start,' 'no key config ascii,' 'write erase,' or changing the
primary key.
Case-1
When the primary key is configured for the first time, the primary key is currently “Active” and can be used for Type-6 encryption
service.
switch#key config ascii <master-key> <retype master-key>
switch#show encryption mkey info all
Master-Key ID : 1
-------------------------------- --------------------------------------------------
Type : Running (Active)
Key-Hash(first 16 chars) : SHA512: TNESx8lzL5C1fRpb
Protection-Type : Software
Length : 20
Last updated : 2024-11-03 16:35:26.074 IST
-------------------------------- --------------------------------------------------

Note
|
The configuration won’t be there post device-reload, as it is not saved to startup config (using copy run start).
|
Case-2
When the primary key is encrypted using the Type-6 encryption command, the Protection-type changes to Hardware, indicating that the stored-master-key has been encrypted using the Trust Anchor Module (TAM) provided encryption algorithm.
switch(config)#feature password encryption aes tam
switch#show encryption mkey info all
Master-Key ID : 1
-------------------------------- --------------------------------------------------
Type : Running (Active)
Key-Hash(first 16 chars) : SHA512: TNESx8lzL5C1fRpb
Protection-Type : Hardware
Length : 20
Last updated : 2024-11-03 16:35:26.074 IST
-------------------------------- --------------------------------------------------
Case-3
When the primary key is modified, the following two scenarios are observed:
-
If an active “Running” primary key exists, it will be replaced with a newly configured primary key of the same type.
switch#key config ascii <current master-key> <new master-key> <retype new master-key>
switch#show encryption mkey info all
Master-Key ID : 1
-------------------------------- --------------------------------------------------
Type : Running (Active)
Key-Hash(first 16 chars) : SHA512: PWEQJonK0xzt21NJ
Protection-Type : Hardware
Length : 26
Last updated : 2024-11-05 05:33:37.626IST
-------------------------------- --------------------------------------------------
-
When there is an active “Running & Startup” primary key, the existing primary key is replaced with a new configured primary
key. The show command displays the following two separate primary keys:
-
One for the old primary key which is set to a new type as “Startup” and is marked as “Inactive” as this primary key can be
used only after the next device-reload.
-
Other for newly configured primary key, which is of type “Running” and is currently active and can be used for new session
(until device-reload).
switch#show encryption mkey info all
Master-key ID : 1
-------------------------------- --------------------------------------------------
Type : Startup (Inactive)
Key-Hash(first 16 chars) : SHA512: TNESx8lzL5C1fRpb
Protection-Type : Hardware
Length : 20
Last updated : 2024-11-03 16:35:26.074 IST
-------------------------------- --------------------------------------------------
Master-Key ID : 2
-------------------------------- --------------------------------------------------
Type : Running (Active)
Key-Hash(first 16 chars) : SHA512: PWEQJonK0xzt21NJ
Protection-Type : Hardware
Length : 26
Last updated : 2024-11-05 05:33:37.626IST
-------------------------------- --------------------------------------------------
Case-4
When you copy the running configuration to startup configuration, the primary key configured in running-config is stored in
startup-config. Its type changes to “Running & Startup,” indicating the key is active and can be used for Type-6 encryption
service.
switch# copy r s
switch#show encryption mkey info all
Master-key ID : 1
-------------------------------- --------------------------------------------------
Type :Running & Startup (Active)
Key-Hash(first 16 chars) : SHA512: TNESx8lzL5C1fRpb
Protection-Type : Hardware
Length : 20
Last updated : 2024-11-03 16:35:26.074 IST
-------------------------------- --------------------------------------------------

Note
|
-
The configuration is there post device-reload, as it is saved to startup config (using copy run start).
-
If copy run start is not performed before device-reload, there may be loss of primary key or if there was an existing primary
key in startup-config, the last stored state of that primary key is retained post-reload.
|