Console & VTY Line Configuration (Cisco IOS)
Securing access lines is one of the first and most important steps in hardening any Cisco router or switch. By default, the console line has no password and VTY lines either have no password or accept any connection — meaning anyone with physical or network access can enter the device freely. This lab covers how to properly secure both line types, configure session timeouts, enable synchronous logging, and restrict VTY access to specific management hosts using Access Control Lists.
Before starting, ensure you have completed Hostname, Password, and Banner Configuration so your device already has a hostname, enable secret, and MOTD banner in place. Understanding Login Authentication Methods will also help you follow the login options used in this lab.
Console vs VTY Lines — Key Differences
Cisco devices have two primary types of access lines. Understanding their differences helps you apply the right security controls to each:
| Feature | Console Line (line con 0) |
VTY Lines (line vty 0 4) |
|---|---|---|
| Access type | Physical — requires a rollover cable and terminal emulator (PuTTY, SecureCRT) | Remote — over the network via SSH or Telnet |
| Default state | No password required — open by default | No password — connection refused until login or login local configured |
| Number of lines | One (con 0) |
5 by default (vty 0 4); up to 16 on some platforms (vty 0 15) |
| Risk level | Medium — requires physical presence | High — accessible from anywhere on the network |
| Recommended transport | N/A (direct cable) | SSH only — never Telnet in production |
Login Method Options
| Command | Behavior | Recommendation |
|---|---|---|
no login |
No authentication — anyone connects freely | ❌ Never use in production |
login |
Uses a single password set under the line with password [pass] |
⚠️ Basic — no username accountability |
login local |
Requires a username + password from the device's local user database | ✅ Recommended — enforces individual accountability |
Lab Scenario
In this lab, NetsTuts_SW1 will be configured with the following line security settings:
| Line | Login Method | Timeout | Transport | ACL Restriction |
|---|---|---|---|---|
Console (con 0) |
login local |
5 min | N/A | None |
VTY (vty 0 4) |
login local |
10 min | SSH only | MGMT-ACCESS ACL |
1. Securing the Console Line
Explanation
The console line is the physical management port — typically a blue RJ-45 rollover cable connecting to a laptop running a terminal emulator. Even though physical access is required, the console must always be secured. An unsecured console allows anyone who can physically reach the device to access it without any credentials.
Full Console Line Configuration
NetsTuts_SW1>en NetsTuts_SW1#conf t Enter configuration commands, one per line. End with CNTL/Z. NetsTuts_SW1(config)#username admin privilege 15 secret Admin@Secure1! NetsTuts_SW1(config)#line console 0 NetsTuts_SW1(config-line)#login local NetsTuts_SW1(config-line)#exec-timeout 5 0 NetsTuts_SW1(config-line)#logging synchronous NetsTuts_SW1(config-line)#end NetsTuts_SW1# %SYS-5-CONFIG_I: Configured from console by console NetsTuts_SW1#wr Building configuration... [OK] NetsTuts_SW1#
Command Breakdown
| Command | What It Does | Why It Matters |
|---|---|---|
username admin privilege 15 secret Admin@Secure1! |
Creates a local user account with full privilege level 15 | Required before login local — without a local user, you will be locked out |
line console 0 |
Enters console line configuration mode | All commands that follow apply only to the console port |
login local |
Requires username + password from the local database | Provides individual accountability — each admin logs in with their own credentials |
exec-timeout 5 0 |
Disconnects idle sessions after 5 minutes and 0 seconds | Prevents unattended open sessions from being used by unauthorized people |
logging synchronous |
Holds log messages until you press Enter — they do not interrupt typing mid-command | Without this, IOS log messages appear randomly in the middle of your commands making the CLI very difficult to use |
login local. If you enable login local without
any local users defined, you will immediately lock yourself out of the console.
If this happens, follow the ROMMON Password Recovery
procedure to regain access.
Verify Console Line Configuration
NetsTuts_SW1#show running-config | section line con line con 0 exec-timeout 5 0 logging synchronous login local
Expected Login Behavior After Configuration
Press RETURN to get started. ***Unauthorized access is strictly prohibited.*** ***Disconnect immediately if you are not an authorized user.*** User Access Verification Username: admin Password: NetsTuts_SW1>
2. Securing VTY Lines (Remote Access)
Explanation
VTY (Virtual Terminal) lines handle remote CLI access via SSH or Telnet. Unlike the console line, VTY lines are accessible from anywhere on the network — or even from the internet if the device has a public IP. This makes them the highest-risk access point and requires the strictest controls. See SSH vs Telnet Security for a deeper comparison of why SSH must always be used over Telnet.
Most Cisco devices have VTY lines 0–4 (5 simultaneous sessions).
Some platforms support up to VTY 0–15 (16 sessions). You should
configure all available VTY lines — if you only configure vty 0 4
and the device has vty 5 15, those unconfigured lines may be less secure.
Basic VTY Line Configuration (SSH Only)
NetsTuts_SW1>en NetsTuts_SW1#conf t Enter configuration commands, one per line. End with CNTL/Z. NetsTuts_SW1(config)#line vty 0 4 NetsTuts_SW1(config-line)#login local NetsTuts_SW1(config-line)#transport input ssh NetsTuts_SW1(config-line)#exec-timeout 10 0 NetsTuts_SW1(config-line)#logging synchronous NetsTuts_SW1(config-line)#end NetsTuts_SW1#wr Building configuration... [OK] NetsTuts_SW1#
Verify VTY Line Configuration
NetsTuts_SW1#show running-config | section line vty line vty 0 4 exec-timeout 10 0 logging synchronous login local transport input ssh
3. Understanding exec-timeout
The exec-timeout command automatically terminates a session that has
been idle for a specified period. This is a critical security control — an unattended
open session on a network device is a significant risk.
See Login Security and Brute-Force Protection
for complementary session security measures.
Syntax
exec-timeout [minutes] [seconds]
| Example | Timeout Duration | Use Case |
|---|---|---|
exec-timeout 5 0 |
5 minutes, 0 seconds | Standard for console lines |
exec-timeout 10 0 |
10 minutes | Standard for VTY lines |
exec-timeout 0 30 |
30 seconds | High-security environments |
exec-timeout 0 0 |
Never — session stays open indefinitely | ❌ Avoid in production — lab use only |
exec-timeout 0 0 disables the timeout entirely.
This is sometimes used in lab environments to avoid being logged out, but
never use it in production — an unattended privileged session is a
serious security risk.
4. logging synchronous — Why It Matters
By default, Cisco IOS outputs syslog messages to the console at any time — even in the middle of a command you are typing. This can corrupt your input and make the CLI very difficult to use. For full syslog configuration including sending logs to an external server, see Syslog Configuration.
Without logging synchronous (frustrating behavior)
NetsTuts_SW1(config)#interface gig *Mar 1 00:04:22.123: %LINK-3-UPDOWN: Interface GigabitEthernet0/1, changed state to up abitEthernet0/0
interface gigabitEthernet0/0 was broken up — IOS may reject it.
With logging synchronous (clean behavior)
NetsTuts_SW1(config)#interface gigabitEthernet0/0 *Mar 1 00:04:22.123: %LINK-3-UPDOWN: Interface GigabitEthernet0/1, changed state to up NetsTuts_SW1(config-if)#
Apply to Both Console and VTY
NetsTuts_SW1(config)#line console 0 NetsTuts_SW1(config-line)#logging synchronous NetsTuts_SW1(config-line)#exit NetsTuts_SW1(config)#line vty 0 4 NetsTuts_SW1(config-line)#logging synchronous NetsTuts_SW1(config-line)#end
5. Restricting VTY Access with an ACL
Explanation
Even with SSH and login local configured, any host on the network can
attempt to connect to the VTY lines and try to authenticate. Adding an
Access Control List (ACL) to the VTY lines
restricts which source IP addresses are even allowed to
attempt a connection — all other hosts are blocked before authentication.
This is called an access-class — it is a standard ACL applied specifically to a VTY line, not to an interface. For the full ACL configuration lab, see Standard ACL Configuration. For named ACLs and wildcard mask reference, see those dedicated pages.
Step 1: Create the Management ACL
Define which hosts or subnets are permitted to access the VTY lines.
In this example, only the management workstation subnet
(10.10.10.0/24) is allowed:
NetsTuts_SW1>en NetsTuts_SW1#conf t Enter configuration commands, one per line. End with CNTL/Z. NetsTuts_SW1(config)#ip access-list standard MGMT-ACCESS NetsTuts_SW1(config-std-nacl)#permit 10.10.10.0 0.0.0.255 NetsTuts_SW1(config-std-nacl)#deny any log NetsTuts_SW1(config-std-nacl)#exit
deny any log entry logs all blocked connection attempts to
syslog for security monitoring.
The 0.0.0.255 is a wildcard mask
matching all hosts in the /24 subnet.
Step 2: Apply the ACL to VTY Lines
NetsTuts_SW1(config)#line vty 0 4 NetsTuts_SW1(config-line)#access-class MGMT-ACCESS in NetsTuts_SW1(config-line)#login local NetsTuts_SW1(config-line)#transport input ssh NetsTuts_SW1(config-line)#exec-timeout 10 0 NetsTuts_SW1(config-line)#logging synchronous NetsTuts_SW1(config-line)#end NetsTuts_SW1#wr Building configuration... [OK] NetsTuts_SW1#
access-class MGMT-ACCESS in applies the ACL to inbound VTY connections.
Only source IPs matching the ACL are allowed to reach the login prompt.
ip access-group— applied to a physical interface to filter routed traffic. See Applying ACLs to Interfaces.access-class— applied to a VTY line to filter management access connections
Verify ACL and VTY Configuration
NetsTuts_SW1#show running-config | section line vty line vty 0 4 access-class MGMT-ACCESS in exec-timeout 10 0 logging synchronous login local transport input ssh
NetsTuts_SW1#show ip access-lists MGMT-ACCESS
Standard IP access list MGMT-ACCESS
10 permit 10.10.10.0, wildcard bits 0.0.0.255 (15 matches)
20 deny any log (3 matches)
6. Complete Line Security Configuration
The following combines all steps from this lab into a single complete baseline configuration for NetsTuts_SW1:
! ══════════════════════════════════════════════════════════ ! NetsTuts Line Security Baseline — NetsTuts_SW1 ! ══════════════════════════════════════════════════════════ NetsTuts_SW1>en NetsTuts_SW1#conf t Enter configuration commands, one per line. End with CNTL/Z. ! ── Local user account (required for login local) ───────── NetsTuts_SW1(config)#username admin privilege 15 secret Admin@Secure1! ! ── Management ACL ──────────────────────────────────────── NetsTuts_SW1(config)#ip access-list standard MGMT-ACCESS NetsTuts_SW1(config-std-nacl)#permit 10.10.10.0 0.0.0.255 NetsTuts_SW1(config-std-nacl)#deny any log NetsTuts_SW1(config-std-nacl)#exit ! ── Console line ────────────────────────────────────────── NetsTuts_SW1(config)#line console 0 NetsTuts_SW1(config-line)#login local NetsTuts_SW1(config-line)#exec-timeout 5 0 NetsTuts_SW1(config-line)#logging synchronous NetsTuts_SW1(config-line)#exit ! ── VTY lines (SSH only + ACL restriction) ──────────────── NetsTuts_SW1(config)#line vty 0 4 NetsTuts_SW1(config-line)#access-class MGMT-ACCESS in NetsTuts_SW1(config-line)#login local NetsTuts_SW1(config-line)#transport input ssh NetsTuts_SW1(config-line)#exec-timeout 10 0 NetsTuts_SW1(config-line)#logging synchronous NetsTuts_SW1(config-line)#exit ! ── Save ────────────────────────────────────────────────── NetsTuts_SW1(config)#end NetsTuts_SW1#wr Building configuration... [OK] NetsTuts_SW1#
7. Verification Commands
| Command | What It Shows | What to Check |
|---|---|---|
show running-config | section line |
All line configurations (console and VTY) | Confirm login local, exec-timeout, transport input ssh, and access-class are present |
show users |
Currently active sessions — which user on which line | Verify who is currently connected and from which IP address |
show ip access-lists MGMT-ACCESS |
ACL entries and match counters | Confirm the ACL exists and check how many connections have been permitted or denied |
show logging |
Recent log messages including denied connection attempts | Look for %SEC-6-IPACCESSLOGS entries showing blocked VTY attempts |
clear line vty [number] |
Forces a specific VTY session to disconnect | Use to remove stuck or unauthorized sessions |
show users Output Example
NetsTuts_SW1#show users
Line User Host(s) Idle Location
* 0 con 0 admin idle 00:00:00
1 vty 0 admin idle 00:02:14 10.10.10.5
10.10.10.5 — both authenticated as admin.
The asterisk (*) marks the session running this command.
8. Troubleshooting Common Issues
| Problem | Cause | Fix |
|---|---|---|
Locked out of console after login local |
No local user account was created before enabling login local |
Perform password recovery — see ROMMON Password Recovery to boot into ROMMON, bypass startup-config, and recreate the user account |
| SSH connection refused | RSA keys not generated, or transport input ssh not set on VTY lines |
Run crypto key generate rsa modulus 2048 and verify VTY transport. See SSH Configuration for the full setup. |
| Cannot SSH from management host | ACL is blocking the source IP — management host not in permitted subnet | Check show ip access-lists MGMT-ACCESS — add the correct permit statement for the host. See Standard ACL Configuration. |
| Session times out too quickly | exec-timeout set too low |
Increase timeout: exec-timeout 15 0 under the appropriate line |
| Log messages breaking CLI input | logging synchronous not configured on the line |
Add logging synchronous under both line con 0 and line vty 0 4. See Syslog Configuration for full logging setup. |
| VTY lines 5–15 still accessible without restrictions | Configuration only applied to vty 0 4 — higher lines left open |
Apply the same config to line vty 5 15 if the platform supports it |
9. Key Points & Exam Tips
- Always create a local user account before enabling
login localon any line — failing to do so will lock you out immediately. See Hostname, Password, and Banner Configuration for local user account setup. loginuses a single shared line password.login localuses individual username/password pairs — always preferlogin localfor accountability. For centralized authentication, see Login Authentication Methods.exec-timeout 0 0disables the idle timeout — useful in labs but never in production.logging synchronousshould be applied to both console and VTY lines — it prevents log messages from interrupting CLI input. For sending logs to an external server, see Syslog Configuration.transport input sshrestricts VTY lines to SSH only — Telnet is plain text and must never be used in production environments. See SSH vs Telnet Security.access-classapplies a standard ACL to VTY lines to restrict which source IPs can attempt a connection. This is different fromip access-groupwhich is applied to interfaces. See Applying ACLs.- Configure all VTY lines — if a device supports
vty 0 15and you only configurevty 0 4, lines 5–15 may be accessible without your security settings. show usersshows all active sessions including their source IP — use this to identify unauthorized connections.deny any logat the end of the management ACL logs all blocked connection attempts — essential for security monitoring via syslog and syslog server.- The
clear line vty [number]command forcibly disconnects a specific VTY session — useful for removing stuck or suspicious sessions. - For the full AAA framework using RADIUS or TACACS+ instead of local authentication, see AAA Configuration.