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.
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. 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. 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. 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.
| Entry point | What it is | Protected by |
|---|---|---|
| Console (line console 0) | The physical console port, for someone standing next to the device | login 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 EXEC | The move from > to #, where everything can be changed | enable secret, or a user with privilege 15 |
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:
| Type | What it is | Strength |
|---|---|---|
| 0 | Clear text | None |
| 7 | Cisco's reversible encoding, from service password-encryption | Very weak: hides a password from a glance only |
| 5 | Legacy MD5-based password hash | Weak: relatively inexpensive password guesses |
| 8 | PBKDF2 with SHA-256 | Strong |
| 9 | scrypt | Strong; the recommended choice |
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:
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.
Read in arrow direction. Labels describe each stage or hop; connectors show the sequence, not a complete physical cabling plan or time to scale.
hostname SW1
ip domain name example.com
crypto key generate rsa modulus 2048
ip ssh version 2Older releases spell it ip domain-name; both are accepted on current IOS XE. The key is named after hostname.domain.
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)
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 0Both 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 3Type 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 inOnly 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
exitFrom 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-configContinue 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 localGlobal 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
SW1#show ip ssh SSH Enabled - version 2.0 Authentication methods:publickey,keyboard-interactive,password Authentication timeout: 60 secs; Authentication retries: 3 ...
ip ssh version 2.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
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.
SW1#show running-config | include username|enable enable secret 9 $9$hJ2kT0bQ4xW8nE$Xb1... username admin privilege 15 secret 9 $9$Cq7mL5vR3pZ1aD$Kp9...
password 7 anywhere here means a reversible password is still in use.Test from R1, which has an SSH client built in:
R1#ssh -l admin 192.168.10.2 Password: SW1#
Error messages and what they mean
| Symptom or message | Cause | Fix |
|---|---|---|
| % Please define a hostname other than Switch. | Generating keys with the default hostname | Set hostname first |
| % Please define a domain-name first. | No domain name | ip domain name example.com |
| SSH client: connection refused | No RSA keys, or transport input excludes SSH | show ip ssh; generate keys; check the VTY lines |
| Login prompt rejects a correct username and password, or asks only for a password | User created with a typo, or login (line password only) instead of login local | show running-config | section line |
| Password required, but none set | login on a line with no password | Use login local with a user, or set a password |
| SSH works from one subnet but not another | access-class ACL doesn't permit that subnet, or no ip default-gateway | Check the ACL counters and the gateway |
| New SSH logins refused during the configured quiet period | login block-for, without a matching quiet-mode exemption | Use an authenticated console to inspect show login; retry after the quiet period |
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 passwordorusername ... passwordinstead ofsecret. - Thinking
service password-encryptionmakes passwords safe. Type 7 is trivial to reverse. - Securing
line vty 0 4on a switch and forgetting VTY 5 to 15. - Setting
login localbefore 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, neverpassword; type 9 (scrypt) is the strongest. - Personal usernames plus
login localgive 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
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?
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?
A configuration stores an administrator password as a one-way hash. Does that make a short, predictable password safe?
Your first SSH connection offers a host-key fingerprint. What establishes that this key belongs to SW1?
SW1 uses login local and SSH. show users lists admin on a VTY. Does that prove which commands admin ran yesterday?
You type crypto key generate rsa on a new switch and get: % Please define a hostname other than Switch. What do you do?
A configuration has both enable password Cisco123 and enable secret Str0ng!. Which one unlocks privileged EXEC?
show running-config shows: username admin password 7 0822455D0A16. How safe is this password?
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?
Which pair is an example of multi-factor authentication?