Course contents

Chapter 12: Security FundamentalsLesson 9 of 19

Passwords, local users and SSH

Securing console, VTY and enable access, local usernames, password encryption and configuring SSH.

Intermediate · 10 min read

Technical definition

Device access security means protecting the management access to a router or switch: securing the console and VTY lines with individual local user accounts and hashed secrets, using SSH instead of Telnet for encrypted remote sessions, and limiting which addresses may connect.

An audit that read the VTY password off the wire

A security audit of the branch finds that SW1 can be reached with Telnet, every engineer shares the same VTY password, and that password is cisco. Worse, the auditor ran a packet capture on a mirrored switch port and read the password as it crossed the network. Nothing in the logs says who changed what last week, because everyone logs in the same way. This lesson improves login protection with hashed secrets, personal accounts and SSH instead of Telnet. Recording who changed what also needs a separately configured and verified audit mechanism.

Diagram
Telnet versus SSH to SW1
Telnet versus SSH to SW1
Gi1/0/2Gi1/0/5Gi1/0/24Gi0/1Admin PCIP 192.168.10.10SW1Vlan10 192.168.10.2R1Gi0/1 192.168.10.1listeningEavesdroppersame VLAN

Device key: Admin PC, Eavesdropper (laptop) · SW1 (switch) · R1 (router)

Lines show the example’s network connections. The coloured path and envelope follow the current step; its text identifies the sender, receiver and traffic type.

Reading the addresses

IP labels identify interfaces or destinations. Subnet labels identify networks; /n is the prefix length. A router ID (RID) identifies a routing process and need not be a reachable interface.

An IP address alone is not a URL. A web URL includes a scheme such as https://; an address on a router or printer does not imply a website.

  • Admin PC: IP 192.168.10.10
  • SW1: Vlan10 192.168.10.2
  • R1: Gi0/1 192.168.10.1
  • Eavesdropper: same VLAN
  1. 1. Telnet sends everything in clear text. Username, password and every command can be read by anyone who captures the traffic, for example from a mirrored port.
  2. 2. SSH encrypts the whole session. The same login over SSH is unreadable to the eavesdropper. Only SW1 and the admin PC hold the session keys.
  3. 3. Telnet is refused. With transport input ssh on the VTY lines, SW1 rejects Telnet connections outright.

What you are protecting

A Cisco device has several ways in. Each one needs its own protection. If one is left open, the others don't matter.

Diagram
What you are protecting
What you are protecting
Entry pointWhat it isProtected by
Console (line console 0)The physical console port, for someone standing next to the devicelogin local (or a line password)
VTY lines (line vty 0 15)Virtual terminal lines: remote sessions over the network (SSH or Telnet)login local, transport input ssh, optionally an ACL
Privileged EXECThe move from > to #, where everything can be changedenable secret, or a user with privilege 15
Read each row across: the left box names the item, the others describe it.

The basics of line passwords and the login command are in Initial switch and router setup. This lesson goes further: how passwords are stored, personal accounts, and SSH.

Hashes, personal accounts and encryption

How IOS stores passwords

A hash is a one-way calculation: easy to compute from a password, without a decryption operation that recovers it. When you log in, IOS hashes what you type and compares it with the stored hash. The number IOS shows in front of a stored password is its type:

Diagram
How IOS stores passwords
How IOS stores passwords
TypeWhat it isStrength
0Clear textNone
7Cisco's reversible encoding, from service password-encryptionVery weak: hides a password from a glance only
5Legacy MD5-based password hashWeak: relatively inexpensive password guesses
8PBKDF2 with SHA-256Strong
9scryptStrong; the recommended choice
Read each row across: the left box names the item, the others describe it.

Defaults and supported types depend on the platform and release. The examples below explicitly request type 9 with algorithm-type scrypt; verify support and the resulting stored type on the exact lab image.

One-way storage is not protection against every password guess. Someone with a stored hash can test candidate passwords using its algorithm and parameters. Stronger password hashing raises that cost; it does not make a short, predictable password strong. Protect configuration files and use strong, unique credentials.

Credential storage also depends on its job. An administrator login can verify a supplied password against a hash. A protocol that needs the original shared secret cannot simply use that hash instead; use the feature's supported protected storage, such as type 6 where applicable. See Cisco's reversible and non-reversible credential guidance. This is not a migration procedure for every password line.

Why personal accounts

A shared line password tells you only that someone logged in. With a local user database (usernames stored on the device) each admin has their own name, show usersidentifies current sessions, and you can remove one person's access without changing everyone's password. In larger networks the user list moves to a central server; see AAA: RADIUS and TACACS+.

Why SSH

Telnet (TCP port 23) sends every keystroke as plain text. SSH (Secure Shell, TCP port 22) encrypts the whole session and lets the client check it is talking to the real device. More background is in SSH and Telnet. SSH needs an RSA key pair on the device: a public key it can share and a private key it keeps. The keys are what let the two ends agree on secret session keys safely.

Check SW1's host key before sending credentials

A host key is the server's cryptographic key, not your login password. Its fingerprint is a short representation you can compare. On the first connection, compare the offered fingerprint with SW1's expected key from an independently trusted administrative source. An encrypted connection to an unchecked key does not establish that the server is SW1.

On later connections, an unexpected key change needs investigation before entering credentials. Replacement equipment or authorised key rotation can explain a change; so can connecting to the wrong device or interception. Verify the reason and expected key through the trusted administrative process instead of blindly accepting the new key. RFC 4251 host-key trust models explain this distinction. This lesson does not modify any client trust store.

Inside an SSH login to SW1

What happens when the admin PC opens an SSH session to SW1:

Step 1 of 5 · TCP handshake
Admin PC
IP 192.168.10.10
VLAN 10
TCP port 22
SW1
IP 192.168.10.2

Device key: Admin PC (laptop) · SW1 (switch)

Arrows run from each message's sender to its receiver. Rows show message order, not separate cables or elapsed time to scale. Port numbers identify services or conversations, not physical switch sockets.

Reading the addresses

IP labels identify interfaces or destinations. Subnet labels identify networks; /n is the prefix length. A router ID (RID) identifies a routing process and need not be a reachable interface.

An IP address alone is not a URL. A web URL includes a scheme such as https://; an address on a router or printer does not imply a website.

  • Admin PC: IP 192.168.10.10
  • SW1: IP 192.168.10.2

Configuring SSH and local users on SW1

Based on Cisco IOS / IOS XE documentation, not run on a lab device. Create the local user before setting login local on the lines, or you can lock yourself out.

Diagram
Path, step by step
Hostname
not the default
Domain name
ip domain name
RSA keys
2048 bits
Local user
username ... secret
VTY lines
login local, ssh only

Read in arrow direction. Labels describe each stage or hop; connectors show the sequence, not a complete physical cabling plan or time to scale.

SSH has prerequisites. Each step depends on the one before.
hostname SW1 ip domain name example.com crypto key generate rsa modulus 2048 ip ssh version 2

Older releases spell it ip domain-name; both are accepted on current IOS XE. The key is named after hostname.domain.

Example output · based on Cisco documentation; exact format varies by platform and software version
SW1(config)#crypto key generate rsa modulus 2048
The name for the keys will be: SW1.example.com

% The key modulus size is 2048 bits
% Generating 2048 bit RSA keys, keys will be non-exportable...
[OK] (elapsed time was 2 seconds)
Generating the keys turns the SSH server on. Deleting them (crypto key zeroize rsa) turns it off.
enable algorithm-type scrypt secret En4ble-S3cret! username admin privilege 15 algorithm-type scrypt secret Adm1n-S3cret! username helpdesk privilege 1 algorithm-type scrypt secret H3lp-S3cret!

A type 9 enable secret and two personal accounts. privilege 15 lands in privileged EXEC; privilege 1 lands in user EXEC and must still type enable.

line console 0 login local exec-timeout 10 0 line vty 0 15 login local transport input ssh exec-timeout 10 0

Both lines ask for a username. transport input ssh refuses Telnet on the VTY lines. exec-timeout logs out an idle session after 10 minutes.

Extra hardening

service password-encryption security passwords min-length 10 login block-for 120 attempts 3 within 60 ip ssh time-out 60 ip ssh authentication-retries 3

Type 7 for remaining clear-text passwords; a minimum length for new passwords; login-blocking thresholds and SSH login limits.

Keep a way to inspect a login block

A quiet period can block a legitimate administrator's new SSH login. It does not disable the console or remove the console's authentication requirements. Before testing login blocking in this isolated lab, verify console access. From that authenticated console, use show login to inspect the state and remaining quiet time, and show login failures to inspect recorded failures.

A VTY access-class permit is not a quiet-mode exemption. Cisco's IOS XE 17.x login-block guide describes a separate login quiet-mode access-class for that purpose. No exemption is configured here. Inspect the timer and cause before retrying; avoid repeated guesses. Check feature support on the actual platform/image.

access-list 10 permit 192.168.10.0 0.0.0.255 line vty 0 15 access-class 10 in

Only allow SSH sessions from the management subnet. access-class filters who may connect to the VTY lines; the ACL syntax is covered in Standard ACLs.

Standard ACLs explains the wildcard mask in that ACL.

Make the management VLAN reachable first

SSH cannot reach an IP address on an inactive VLAN interface. In this isolated lab, SW1 uses Layer 2 management with IP routing disabled. The admin PC is 192.168.10.10/24 on Gi1/0/2; R1 has an enabled Gi0/1 at 192.168.10.1/24, connected to SW1 Gi1/0/24. Both switch ports below carry untagged VLAN 10 traffic.

vlan 10 name MANAGEMENT exit interface GigabitEthernet1/0/2 switchport mode access switchport access vlan 10 no shutdown exit interface GigabitEthernet1/0/24 switchport mode access switchport access vlan 10 no shutdown exit

From global configuration mode on the isolated lab switch, create VLAN 10 and assign the admin and router links. Check existing port use before applying changes on any other switch.

With normal SVI autostate, VLAN 10 must exist and be active, its SVI must be administratively enabled, and a participating VLAN port must have link up and be forwarding in spanning tree. Setting only no shutdown on Vlan10 does not meet those conditions. Cisco documents these conditions for Catalyst 9300 IOS XE 16.5.1a; the 17.12.x guide also describes port participation and autostate overrides. This lab assumes no overrides.

SSH configuration for SW1

hostname SW1 ip domain name example.com enable algorithm-type scrypt secret En4ble-S3cret! username admin privilege 15 algorithm-type scrypt secret Adm1n-S3cret! service password-encryption security passwords min-length 10 login block-for 120 attempts 3 within 60 ! interface Vlan10 ip address 192.168.10.2 255.255.255.0 no shutdown ip default-gateway 192.168.10.1 ! crypto key generate rsa modulus 2048 ip ssh version 2 ! access-list 10 permit 192.168.10.0 0.0.0.255 line console 0 login local exec-timeout 10 0 line vty 0 15 access-class 10 in login local transport input ssh exec-timeout 10 0 ! end copy running-config startup-config

Continue from global configuration mode after preparing VLAN 10 and its ports above. The RSA keys are stored separately from the configuration file but survive a reload once generated.

After assigning the SVI address, check show vlan brief for VLAN 10 and its access ports, show ip interface brief for Vlan10 up/up, and show spanning-tree vlan 10 for forwarding ports. An up/up SVI alone does not prove that the PC can reach SSH. The same-subnet PC reaches SW1 directly; ip default-gatewaysupplies SW1's next hop for other subnets when IP routing is disabled.

Web (HTTP and HTTPS) management

Many IOS devices can also be managed from a browser. Plain HTTP sends the login in clear text, like Telnet, so if a web interface is needed at all, use HTTPS only and authenticate against the same local users or AAA:

no ip http server ip http secure-server ip http authentication local

Global configuration: turn off clear-text HTTP, turn on HTTPS (the device creates a self-signed certificate) and check logins against the local usernames. If nobody manages the device from a browser, turn off both with no ip http secure-server as well.

Checking SSH, sessions and stored secrets

Example output · based on Cisco documentation; exact format varies by platform and software version
SW1#show ip ssh
SSH Enabled - version 2.0
Authentication methods:publickey,keyboard-interactive,password
Authentication timeout: 60 secs; Authentication retries: 3
...
SSH Enabled - version 2.0 means keys exist and only version 2 is allowed. If it says version 1.99, both 1 and 2 are accepted: add ip ssh version 2.
Example output · based on Cisco documentation; exact format varies by platform and software version
SW1#show users
    Line       User       Host(s)              Idle       Location
*  0 con 0     admin      idle                 00:00:00
   1 vty 0     admin      idle                 00:00:41 192.168.10.10
Who is logged in, on which line, and from where. The asterisk is your own session.

A connected username is not a command history

Authentication checks identity; accounting records selected activity. The show users snapshot identifies current sessions, not every earlier command or the person responsible for a past change. SSH encryption protects the session in transit; it does not enable command accounting.

For an IOS XE audit design, distinguish EXEC session accounting from command accounting. Verify the required records reach the intended collector and are retained before relying on them. See Cisco IOS XE accounting types and the AAA lesson. No accounting method or server configuration is added by this local-login lab.

Example output · based on Cisco documentation; exact format varies by platform and software version
SW1#show running-config | include username|enable
enable secret 9 $9$hJ2kT0bQ4xW8nE$Xb1...
username admin privilege 15 secret 9 $9$Cq7mL5vR3pZ1aD$Kp9...
secret 9: scrypt hashes. A password 7 anywhere here means a reversible password is still in use.

Test from R1, which has an SSH client built in:

Example output · based on Cisco documentation; exact format varies by platform and software version
R1#ssh -l admin 192.168.10.2
Password:

SW1#

Error messages and what they mean

Diagram
Error messages and what they mean
Error messages and what they mean
Symptom or messageCauseFix
% Please define a hostname other than Switch.Generating keys with the default hostnameSet hostname first
% Please define a domain-name first.No domain nameip domain name example.com
SSH client: connection refusedNo RSA keys, or transport input excludes SSHshow ip ssh; generate keys; check the VTY lines
Login prompt rejects a correct username and password, or asks only for a passwordUser created with a typo, or login (line password only) instead of login localshow running-config | section line
Password required, but none setlogin on a line with no passwordUse login local with a user, or set a password
SSH works from one subnet but not anotheraccess-class ACL doesn't permit that subnet, or no ip default-gatewayCheck the ACL counters and the gateway
New SSH logins refused during the configured quiet periodlogin block-for, without a matching quiet-mode exemptionUse an authenticated console to inspect show login; retry after the quiet period
Read each row across: the left box names the item, the others describe it.

Password policies beyond the device

The CCNA also expects you to know the ideas behind good access control, not just the commands:

  • Password policy: a long minimum length, checking new passwords against lists of common or leaked ones, no reuse, and changing passwords when someone leaves or one is exposed. (Older policies, and the exam, also mention a mix of character types.)
  • Multi-factor authentication (MFA): proving who you are with two or more different kinds of factor: something you know (a password), something you have (a phone app or token) and something you are (a fingerprint).
  • Certificates: a digital document, signed by a trusted authority, that proves a device or user owns a key. SSH public-key logins and 802.1X can use them instead of passwords.
  • Biometrics: fingerprints, faces or voices used as the "something you are" factor.

Slips that leave a device open

  • Using enable password or username ... password instead of secret.
  • Thinking service password-encryption makes passwords safe. Type 7 is trivial to reverse.
  • Securing line vty 0 4 on a switch and forgetting VTY 5 to 15.
  • Setting login local before any username exists, then being locked out after the session ends.
  • Leaving SSH version 1 allowed (version 1.99 in show ip ssh).
  • Forgetting that generating RSA keys needs a hostname and a domain name first.

Audits regularly turn up old password 7 lines left over from a template copied years earlier. show running-config | include password helps locate them for review. Migrate administrator-login entries to supported strong secrets; inspect each protocol's credential requirements before changing other password lines.

Exam tip: be able to list the SSH steps in order (hostname, domain name, RSA keys, local user, login local, transport input ssh) and spot the missing one in a configuration. Know that enable secret overrides enable password, that type 7 is reversible while 5, 8 and 9 are hashes, that Telnet is TCP 23 and SSH is TCP 22, and that access-class (not access-group) applies an ACL to VTY lines. Questions on MFA, certificates and biometrics test the concepts, not commands.

Rules to remember for device access

  • Protect every entry point: console, VTY lines and privileged EXEC.
  • Use secret, never password; type 9 (scrypt) is the strongest.
  • Personal usernames plus login local give accountability.
  • SSH needs a hostname, domain name, RSA keys and a user; then transport input ssh.
  • Limit VTY access with access-class, idle timeouts and login blocking.

Test yourself on device access

Predict · scenario 1

SW1 is in quiet mode with no exemption configured. Its VTY ACL permits the admin PC. Does that permit alone let a new SSH login bypass the quiet period?

Predict · scenario 2

Vlan10 has an IP address and no shutdown, but no VLAN 10 port has an active forwarding link. What should you check before regenerating SSH keys?

Predict · scenario 3

A configuration stores an administrator password as a one-way hash. Does that make a short, predictable password safe?

Predict · scenario 4

Your first SSH connection offers a host-key fingerprint. What establishes that this key belongs to SW1?

Predict · scenario 5

SW1 uses login local and SSH. show users lists admin on a VTY. Does that prove which commands admin ran yesterday?

Predict · scenario 6

You type crypto key generate rsa on a new switch and get: % Please define a hostname other than Switch. What do you do?

Predict · scenario 7

A configuration has both enable password Cisco123 and enable secret Str0ng!. Which one unlocks privileged EXEC?

Predict · scenario 8

show running-config shows: username admin password 7 0822455D0A16. How safe is this password?

Predict · scenario 9

VTY lines have login local and transport input ssh, and SSH keys exist. An admin can SSH in from 192.168.10.10 but not from 192.168.20.10. What is a likely cause?

Predict · scenario 10

Which pair is an example of multi-factor authentication?

FAQ

What is the difference between password and secret?
For the classic administrator-login examples here, password can leave clear text or weak reversible type 7, while secret stores a one-way hash. A hash is not decrypted back to the password, but guesses can be checked against it; weak passwords remain risky. Prefer a supported strong secret type for administrator logins. Other protocols may require retrievable credentials, so their storage must follow the exact platform and feature guide.
Why does SSH need a domain name?
By default the router names its RSA key pair after its hostname and domain name, for example SW1.example.com. Without a hostname other than the default and an ip domain name, crypto key generate rsa refuses to run unless you give the keys a label, and without keys SSH can't start.
What does login local do?
It tells a line (console or VTY) to check a username and password against the device's local user database instead of a shared line password. Individual accounts identify the login, but login local does not automatically enable a history of commands or configuration changes. Command accounting and retained records need separate configuration and verification.
Should I still use SSH version 1?
No. Version 1 has known weaknesses. Use ip ssh version 2 so the device refuses version 1 clients. Version 2 needs an RSA key of at least 768 bits; use 2048 bits or more.