Remote Access and Device Management (SSH, Telnet, Console)
Console Port Security
- Concept: Securing physical access to a Cisco IOS device via the console port. By default, no password is required, posing a security risk if physical access is gained.
- Details:
- There is only one console line (
0), meaning only one user can configure the device via console at a time. - Passwords are hidden (not displayed) during entry.
exec-timeoutautomatically logs out inactive sessions to prevent unauthorized access if the administrator leaves their desk.
- There is only one console line (
Router(config)# line console 0
Router(config-line)# password ccna
Router(config-line)# login
! OR, to require a local username/password instead of a line password:
Router(config)# username jeremy secret ccnp
Router(config)# line console 0
Router(config-line)# login local
! Set inactivity timeout to 3 minutes and 30 seconds
Router(config-line)# exec-timeout 3 30
Things to note: If both a line password and login local are configured, login local takes precedence, and the line password is ignored.
Layer 2 Switch Management IP
- Concept: Layer 2 switches do not route packets or build routing tables. However, they require an IP address to be managed remotely (via SSH/Telnet) from a different subnet.
- Details:
- Management IP is assigned to an SVI (Switch Virtual Interface).
- An
ip default-gatewaymust be configured so the switch can send management traffic to a router for off-subnet destinations.
Switch(config)# interface vlan 10
Switch(config-if)# ip address 192.168.10.50 255.255.255.0
Switch(config-if)# no shutdown
Switch(config)# ip default-gateway 192.168.10.1
Things to note: The ip default-gateway command is the Layer 2 equivalent of a default route (ip route 0.0.0.0 0.0.0.0). Without it, the switch can only communicate with devices in its local VLAN.
Telnet (Legacy Protocol)
- Concept: Telnet (Teletype Network, developed in 1969) allows remote CLI access but transmits all data (including usernames and passwords) in plain text. It is largely replaced by SSH due to severe security vulnerabilities.
- Details:
- Uses TCP Port 23.
- Configured on VTY (Virtual Teletype) lines. Cisco devices typically have 16 VTY lines (
0through15), allowing up to 16 concurrent remote sessions. - Requires an
enable secretto be configured, otherwise privileged EXEC mode access will be denied upon connection.
Router(config)# enable secret ccnp
Router(config)# username admin secret ccnp
! Optional: Restrict access via ACL (e.g., only allow 192.168.1.10)
Router(config)# access-list 10 permit host 192.168.1.10
Router(config)# line vty 0 15
Router(config-line)# login local
Router(config-line)# exec-timeout 5 0
Router(config-line)# transport input telnet
Router(config-line)# access-class 10 in
Things to note: Do not confuse access-class (applies ACL to VTY lines) with ip access-group (applies ACL to a physical/logical interface).
SSH (Secure Shell)
- Concept: SSH (Secure Shell, developed in 1995) provides encrypted remote CLI access, protecting data integrity and confidentiality. SSHv2 (released in 2006) is the secure standard and should always be used.
- Details:
- Uses TCP Port 22.
- Requires a K9 IOS image (supports cryptographic features). NPE (No Payload Encryption) images do not support SSH.
- Prerequisites for RSA Key Generation: The device must have a non-default
hostnameand anip domain-nameconfigured. The combination forms the FQDN (Fully Qualified Domain Name), which names the RSA key pair. - RSA modulus size must be at least 768 bits to support SSHv2 (2048 bits is recommended for modern security).
login localis mandatory for SSH; the basiclogincommand will not work.
graph TD
A[1. Configure Hostname] --> B[2. Configure IP Domain Name]
B --> C[3. Generate RSA Keys]
C --> D[4. Create Local Username/Secret]
D --> E[5. Configure VTY Lines: login local & transport input ssh]
E --> F[6. Optional: Apply access-class ACL]
! Step 1 & 2: Prerequisites for RSA Keys
Switch(config)# hostname SW1
SW1(config)# ip domain-name jeremysitlab.com
! Step 3: Generate RSA Keys (FQDN becomes SW1.jeremysitlab.com)
SW1(config)# crypto key generate rsa modulus 2048
! Note: Can also use 'crypto key generate rsa' and specify modulus interactively
! Step 4: Local Authentication
SW1(config)# enable secret ccnp
SW1(config)# username admin secret ccnp
! Step 5: Enforce SSHv2 and Configure VTY
SW1(config)# ip ssh version 2
SW1(config)# line vty 0 15
SW1(config-line)# login local
SW1(config-line)# exec-timeout 5 0
SW1(config-line)# transport input ssh
! Step 6: Optional ACL restriction
SW1(config-line)# access-class 10 in
Things to note:
- If you see SSH version 1.99, it means the device supports both SSHv1 and SSHv2.
- If you receive the error “Please define a domain-name first” when generating keys, it means the
ip domain-namecommand is missing. - If you receive “Please define a hostname other than Router”, the default hostname is still active.
Comparison: Telnet vs. SSH
| Feature | Telnet | SSH (Secure Shell) |
|---|---|---|
| Port | TCP 23 | TCP 22 |
| Encryption | None (Plain Text) | Yes (Encrypted payload) |
| Authentication | login or login local |
login local only (Username required) |
| Prerequisites | Enable secret, VTY config | Hostname, Domain Name, RSA Keys, K9 IOS |
| Security | Highly insecure (sniffable via Wireshark) | Secure (industry standard) |
| VTY Command | transport input telnet |
transport input ssh |
Common Misconceptions & Exam Traps
- RSA Key Generation Failure: The exam often tests the prerequisite order. You cannot generate RSA keys without both a non-default
hostnameand anip domain-name. - VTY Line Display: In the
show running-config, VTY lines may appear split (e.g.,line vty 0 4andline vty 5 15). This is a legacy IOS display artifact; configuringline vty 0 15applies the settings to all 16 lines. - Access Control:
transport input allallows Telnet, SSH, and other legacy protocols. Best practice is strictlytransport input ssh. - NPE vs. K9: NPE (No Payload Encryption) IOS images are exported to countries with encryption restrictions and do not support SSH. Always look for “K9” in the
show versionoutput.
Command Summary Reference
! Console Security
line console 0
password <password>
login
login local
exec-timeout <minutes> <seconds>
! Layer 2 Management
interface vlan <vlan-id>
ip address <ip> <subnet-mask>
no shutdown
ip default-gateway <ip-address>
! Telnet / SSH VTY Configuration
line vty 0 15
login local
exec-timeout <minutes> <seconds>
transport input telnet ! Allows only Telnet
transport input ssh ! Allows only SSH (Best Practice)
transport input telnet ssh ! Allows both
transport input all ! Allows all supported protocols
access-class <acl-number> in ! Applies ACL to VTY lines
! SSH Specific Configuration
hostname <name> ! Must not be 'Router'
ip domain-name <domain.com> ! Required for FQDN
crypto key generate rsa modulus 2048 ! Min 768 for SSHv2, 2048 recommended
ip ssh version 2 ! Forces SSHv2 only