line vty 0 4
Enters line configuration mode for virtual terminal (VTY) lines 0 through 4 to configure remote access settings like Telnet/SSH, ACLs, and timeout parameters.
Definition: line vty 0 4 is a Cisco IOS global config command. Enters line configuration mode for virtual terminal (VTY) lines 0 through 4 to configure remote access settings like Telnet/SSH, ACLs, and timeout parameters.
Overview
The `line vty 0 4` command is a fundamental Cisco IOS configuration command used to enter line configuration mode for virtual terminal (VTY) lines 0 through 4. VTY lines are logical interfaces that allow remote access to a Cisco device via Telnet or SSH. This command is critical for network administrators who need to manage devices remotely, as it enables the configuration of authentication, access control, and session parameters. Understanding VTY configuration is essential for CCNA and CCNP candidates because remote access is a core component of network management and security.
The networking concept behind VTY lines is that they represent virtual connections to the device's command-line interface (CLI). Unlike physical console or auxiliary ports, VTY lines are not tied to a specific hardware interface; instead, they are dynamically allocated when a remote session is initiated. By default, Cisco devices support up to 16 VTY lines (0-15), but the `line vty 0 4` command configures the first five lines. This range is commonly used to limit the number of concurrent remote sessions, balancing accessibility with security.
Network engineers reach for this command when they need to enable or restrict remote management access. For example, after initial device configuration via console, you would configure VTY lines to allow SSH or Telnet from specific management subnets. Alternatives include using the console line for direct physical access, but that is impractical for remote management. The `line vty` command is also used in conjunction with access-class (ACL) to restrict source IP addresses, transport input to specify allowed protocols (e.g., SSH only), and exec-timeout to set idle session timeouts.
In the broader network configuration workflow, VTY configuration is typically performed after basic interface and IP addressing setup. It is part of the device hardening process, often following the creation of local user accounts and enable passwords. During troubleshooting, VTY issues can manifest as inability to connect remotely, authentication failures, or session drops. The `show line` command is used to verify VTY status, while `show users` displays active sessions.
Important IOS behaviors include: VTY configuration is stored in the running configuration and must be saved to startup-config to persist. Privilege level 15 (enable mode) is required to enter line configuration mode. The `transport input` command determines which protocols are allowed; by default, all protocols are permitted, which is a security risk. The `exec-timeout` command sets the idle timeout; default is 10 minutes. The `login` command enables password authentication; if not configured, remote access may be denied. Buffered output is not directly affected by VTY commands, but logging synchronous can be enabled to prevent console messages from interrupting command input. Understanding these behaviors helps avoid common misconfigurations that can lock out remote access.
line vty 0 4When to Use This Command
- Configuring password authentication for remote Telnet/SSH access to a router.
- Applying an access-class to restrict which IP addresses can initiate remote sessions.
- Setting the exec-timeout to automatically disconnect idle administrative sessions.
- Enabling SSH and disabling Telnet for secure remote management.
Parameters
| Parameter | Syntax | Description |
|---|---|---|
| first-line-number | <0-15> | Specifies the first VTY line number in the range. For example, 0 in 'line vty 0 4'. Valid values are 0 to 15. Common mistake: using a number higher than 15 or forgetting that the range is inclusive. |
| last-line-number | <0-15> | Specifies the last VTY line number in the range. For example, 4 in 'line vty 0 4'. Must be equal to or greater than the first line number. Common mistake: configuring a range that is too large (e.g., 0 15) without considering security implications. |
Command Examples
Basic VTY password and login configuration
line vty 0 4
password cisco
loginRouter(config-line)#
The command enters VTY line configuration mode, sets the password to 'cisco', and enables password checking at login. No output is shown except the prompt change.
VTY configuration with ACL and timeout
line vty 0 4
access-class 10 in
exec-timeout 5 0
transport input sshRouter(config-line)#
Applies ACL 10 to restrict incoming VTY connections, sets exec timeout to 5 minutes, and limits transport input to SSH only. No output is shown except the prompt change.
Understanding the Output
The 'line vty 0 4' command itself does not produce output; it changes the CLI prompt to indicate line configuration mode. To verify VTY settings, use 'show running-config | section line vty' or 'show line'. In 'show running-config', look for lines under 'line vty 0 4' such as 'password', 'login', 'transport input', 'exec-timeout', and 'access-class'.
A common good configuration includes 'transport input ssh' and 'exec-timeout 5 0'. A bad configuration might have 'transport input all' (allowing insecure Telnet) or no 'login' command (allowing access without password).
Configuration Scenarios
Configure SSH Access on VTY Lines with ACL Restriction
A network administrator needs to enable secure remote management of a Cisco router from a management subnet (192.168.10.0/24) while blocking all other sources. SSH must be the only allowed protocol.
Topology
Management PC (192.168.10.10)---(Gi0/0) R1 (192.168.10.1)---InternetSteps
- 1.Step 1: Enter global configuration mode: configure terminal
- 2.Step 2: Create an ACL to permit only the management subnet: access-list 10 permit 192.168.10.0 0.0.0.255
- 3.Step 3: Enter VTY line configuration mode for lines 0 to 4: line vty 0 4
- 4.Step 4: Apply the ACL to restrict incoming connections: access-class 10 in
- 5.Step 5: Allow only SSH connections: transport input ssh
- 6.Step 6: Set login authentication to use local database: login local
- 7.Step 7: Set idle timeout to 5 minutes: exec-timeout 5 0
- 8.Step 8: Exit and save configuration: end; copy running-config startup-config
! access-list 10 permit 192.168.10.0 0.0.0.255 ! line vty 0 4 access-class 10 in transport input ssh login local exec-timeout 5 0 !
Verify: Use 'show line vty 0 4' to verify configuration. Expected output shows 'Transport input: ssh' and 'Access-class: 10'. Use 'show access-lists 10' to verify ACL. Attempt SSH from 192.168.10.10 should succeed; from other IPs should fail.
Watch out: Forgetting to configure 'login local' or a local username/password will cause SSH authentication to fail. Also, ensure the ACL permits the management subnet; a common mistake is using the wrong wildcard mask.
Configure Telnet Access with Timeout and Domain Authentication
A company uses a TACACS+ server for centralized authentication. The network engineer needs to enable Telnet access on a switch for legacy devices, but only from the internal network (10.0.0.0/8).
Topology
Management Server (10.0.0.10)---(Vlan10) SW1 (10.0.0.1)---Access LayerSteps
- 1.Step 1: Enter global configuration mode: configure terminal
- 2.Step 2: Configure TACACS+ server: tacacs-server host 10.0.0.100 key cisco123
- 3.Step 3: Enable AAA authentication: aaa new-model; aaa authentication login default group tacacs+ local
- 4.Step 4: Create ACL to permit internal network: access-list 20 permit 10.0.0.0 0.255.255.255
- 5.Step 5: Enter VTY line configuration mode: line vty 0 4
- 6.Step 6: Apply ACL: access-class 20 in
- 7.Step 7: Allow Telnet: transport input telnet
- 8.Step 8: Set authentication to use AAA: login authentication default
- 9.Step 9: Set timeout to 10 minutes: exec-timeout 10 0
- 10.Step 10: Exit and save: end; copy running-config startup-config
! tacacs-server host 10.0.0.100 key cisco123 aaa new-model aaa authentication login default group tacacs+ local access-list 20 permit 10.0.0.0 0.255.255.255 ! line vty 0 4 access-class 20 in transport input telnet login authentication default exec-timeout 10 0 !
Verify: Use 'show line vty 0 4' to confirm transport input and access-class. Use 'show aaa sessions' to see active AAA sessions. Attempt Telnet from 10.0.0.0/8 should succeed; from other networks should fail.
Watch out: If the TACACS+ server is unreachable, AAA fallback to local must be configured; otherwise, authentication fails. Also, ensure the switch has a route to the TACACS+ server.
Troubleshooting with This Command
When troubleshooting VTY line issues, the primary command is `show line vty 0 4` (or the specific line number). Healthy output displays the line status as 'ready', transport input as configured (e.g., 'ssh' or 'telnet'), and an access-class if applied. Problem indicators include 'idle' or 'no active session' when a session should be active, or 'access denied' in logs. Key fields to examine are 'Modem' (should be 'no'), 'Host' (shows connected host IP), and 'Active' (shows session count).
Common symptoms this command helps diagnose include: - Unable to connect remotely: Check if transport input allows the protocol (e.g., missing 'ssh'). Verify access-class permits the source IP. Check if login authentication is configured. - Session drops after idle: Check exec-timeout value; default is 10 minutes. If set too low, sessions terminate prematurely. - Authentication failures: Use `debug aaa authentication` to see AAA process. Verify local usernames or TACACS+ server reachability. - All VTY lines in use: Use `show users` to see active sessions. Increase VTY range (e.g., line vty 0 15) or disconnect idle sessions with `clear line`.
Diagnostic flow: 1. Check physical connectivity: Can you ping the device from the management host? 2. Verify VTY configuration: `show running-config | section line vty` 3. Check line status: `show line vty 0 4` – look for 'ready' or 'idle'. 4. Test with Telnet/SSH client: Observe error messages (e.g., 'Connection refused' indicates transport input mismatch). 5. Check logs: `show logging` for authentication failures or ACL denies. 6. Use debug: `debug ip telnet` or `debug ip ssh` for protocol-specific issues.
Correlate with other commands: `show ip interface brief` to verify management interface is up; `show access-lists` to confirm ACL counters increment; `show users` to see active sessions and their source IPs. For AAA issues, `show aaa servers` and `test aaa group tacacs+ username password` help isolate authentication problems.
CCNA Exam Tips
CCNA exam tip: Remember that 'line vty 0 4' configures five simultaneous virtual terminal sessions (0 through 4).
CCNA exam tip: The 'login' command is required to enable password authentication; without it, no password is prompted.
CCNA exam tip: For SSH, you must also configure a domain name and generate RSA keys using 'crypto key generate rsa'.
CCNA exam tip: The 'transport input' command can be set to 'telnet', 'ssh', 'all', or 'none'; exam scenarios often test restricting to SSH only.
Common Mistakes
Mistake 1: Forgetting to issue the 'login' command after setting a password, resulting in no authentication required.
Mistake 2: Using 'line vty 0 4' but only configuring one line; the configuration applies to all five lines.
Mistake 3: Setting 'transport input telnet' when SSH is required, leaving the device vulnerable to unencrypted access.
line vty 0 4 vs access-class [acl] in
These commands are often confused because both are involved in managing remote access to a Cisco router. 'line vty 0 4' enters the configuration context for VTY lines, while 'access-class [acl] in' is a specific command applied within that context to filter incoming connections. Understanding their distinct roles is crucial for correct configuration.
| Aspect | line vty 0 4 | access-class [acl] in |
|---|---|---|
| Scope | Global configuration mode for VTY lines 0-4 | Line configuration mode for a specific line |
| Configuration mode | Entered from global config | Applied within line config mode |
| Persistence | Saved as part of the running-config | Saved under the specific line configuration |
| Precedence | Prerequisite for many line commands | Applied after entering line mode; overrides no other mode |
| Typical use | Start configuring VTY parameters (transport, exec-timeout, etc.) | Restrict inbound Telnet/SSH by source IP |
Use line vty 0 4 when you need to enter the configuration context for VTY lines to set global parameters like transport protocols or timeouts.
Use access-class [acl] in when you need to filter incoming Telnet/SSH connections based on source IP addresses on a specific VTY line.
Platform Notes
In IOS-XE (e.g., Catalyst 9000 switches), the `line vty` command syntax is identical to classic IOS. However, IOS-XE introduces the `ip ssh version 2` command for SSH configuration, and VTY lines support additional parameters like `session-limit`. The output of `show line` may include additional fields like 'Protocol' and 'Idle Time'.
For NX-OS (e.g., Nexus switches), the equivalent is `line vty` but with different defaults: NX-OS uses `transport input ssh` by default and requires `feature ssh` to enable SSH. The command `show line vty` works similarly, but NX-OS also uses `show users` for active sessions. For ASA firewalls, VTY lines are not used; instead, remote access is configured via `ssh` or `telnet` commands under the management interface, e.g., `ssh 192.168.1.0 255.255.255.0 management`.
ASA uses `http` for web access. In IOS-XR (e.g., ASR 9000), the concept of VTY lines is replaced by `vty-pool` configuration under `line template`. The command `line vty` does not exist; instead, use `line template vty` and apply it to a VRF.
For example: `line template vty default` then `exec-timeout 0 0`. The `show line` command is replaced by `show users` and `show line summary`. These differences are important for multi-platform environments.
Related Commands
access-class [acl] in
Restricts incoming or outgoing Telnet/SSH access to a router line (VTY, AUX, console) by applying an ACL that filters source IP addresses.
exec-timeout [min] [sec]
Sets the inactivity timeout for an EXEC session on a line, automatically logging out idle users to free up resources and enhance security.
show line
Displays line configuration and status information for console, auxiliary, and vty lines, used to verify line settings and monitor user connections.
show running-config
Displays the current active configuration in DRAM, showing all non-default settings.
Practice for the CCNA 200-301
Test your knowledge with practice questions covering all CCNA 200-301 exam domains.
Practice CCNA 200-301 Questions