VTY (Virtual TeletYpe) 是 Cisco 設備遠端 CLI 管理的邏輯線路 (預設 0~4 共 5 條,新版支援 0~15 共 16 條)。正確配置 VTY 啟用順序、傳輸協議 (SSH/Telnet)、登入驗證與特權保護,是確保遠端管理安全的關鍵。本文詳細說明 VTY 管理全流程。
line vty 0 15 一次啟用 16 條。no line vty 5 將關閉 5 及之後所有線路 (6~15)。Router(config-line)# transport input ?
all All protocols
none No protocols
ssh TCP/IP SSH protocol
telnet TCP/IP Telnet protocol
rlogin Unix rlogin
... (lat, mop, nasi, pad, udptn)
Router# show line vty 0
...
Allowed input transports are ssh telnet.
Allowed output transports are ssh telnet.
Preferred transport is ssh.
line vty 0 15
password VtyStr0ngPass
login
! 或
login local ! 使用本地用戶資料庫
! 或
login authentication AAA_LIST ! 使用 AAA Server (TACACS+/RADIUS)
line vty 0 15
transport input ssh
! 產生金鑰
crypto key generate rsa modulus 2048
ip ssh version 2
ip ssh authentication-retries 3
ip ssh time-out 60
access-list 23 permit 10.10.10.0 0.0.0.255 ! 管理網段
line vty 0 15
access-class 23 in
VTY 登入後處於 User EXEC (Router>),需 enable 進入特權。務必配置:
enable secret Admin@Secret2024
service password-encryption
line vty 0 15
rotary 5 ! 新埠號 = 3005
transport input telnet ssh
access-list 101 deny tcp any any eq 23
access-list 101 permit ip any any
line vty 0 15
access-class 101 in
line vty 0 15
exec-timeout 10 0 ! 10 分鐘無操作斷線
session-timeout 30 ! 30 分鐘絕對逾時
logging synchronous ! 避免日志打斷輸入
history size 200 ! 指令歷史 200 條
show line vty 0 確認 Allowed input transports 僅 ssh。show privilege 顯示 15。show run | section line vty 確認所有參數生效。