การบริหาร Router และ Switch จากระยะไกลเป็นงานประจำของ Network Engineer แต่ Management Channel ที่ใช้เชื่อมต่ออุปกรณ์ถือเป็นหนึ่งในจุดสำคัญด้าน Security เพราะหาก Credential หรือ Management Traffic ถูกดักจับ ผู้ไม่หวังดีอาจเข้าถึง Network Infrastructure ได้โดยตรง
SSH หรือ Secure Shell เป็น Protocol หลักที่ใช้สำหรับ Secure Remote Management แทน Telnet บนอุปกรณ์ Cisco สมัยใหม่ บทความนี้อธิบายตั้งแต่ SSH, RSA Key, Local User, AAA, VTY, Access Control List, Source Interface และ Management Plane Hardening พร้อม Cisco Lab และแนวทาง Troubleshooting
สารบัญ
- SSH คืออะไร?
- ทำไม Network Engineer ควรใช้ SSH?
- SSH Architecture
- SSH กับ Telnet ต่างกันอย่างไร?
- SSH ใช้ Port อะไร?
- สิ่งที่ต้องมีก่อนเปิด SSH บน Cisco
- Hostname และ Domain Name
- RSA Key คืออะไร?
- Local User และ Secret
- VTY Line คืออะไร?
- SSH Version
- Cisco SSH Basic Lab
- SSH ทำงานร่วมกับ AAA อย่างไร?
- จำกัด SSH ด้วย ACL
- Management Source Network
- Session Timeout และ Login Protection
- Verification Commands
- SSH Troubleshooting
- SSH Hardening
- Secure Management Architecture
- Best Practices
- FAQ
- บทสรุป
ภาค 1: พื้นฐาน Secure Remote Management
SSH คืออะไร?
SSH หรือ Secure Shell เป็น Protocol สำหรับสร้าง Secure Channel ระหว่าง Client และ Remote Device ผ่าน Network
ตัวอย่าง:
Administrator PC
|
| SSH
v
+---------------+
| Cisco Router |
+---------------+
SSH ถูกใช้อย่างแพร่หลาย สำหรับบริหาร:
- Router
- Switch
- Firewall
- Linux Server
- Network Appliance
- Cloud Infrastructure
ทำไม Network Engineer ควรใช้ SSH?
Network Device เป็น Infrastructure ที่มีสิทธิ์ควบคุม Network จำนวนมาก
หาก Management Protocol ไม่ปลอดภัย:
Administrator
|
| Management Traffic
v
Network
|
v
Router / Switch
Credential และ Management Information อาจมีความเสี่ยงระหว่างทาง
SSH จึงถูกออกแบบมาเพื่อให้ Confidentiality, Integrity และ Server Authentication แก่ Remote Management Session ตาม Protocol และ Configuration ที่ใช้งาน
ภาค 2: SSH Architecture
SSH ทำงานอย่างไร?
ภาพรวม:
SSH Client
|
| TCP Connection
v
SSH Server
|
v
Cryptographic Negotiation
|
v
Server Authentication
|
v
User Authentication
|
v
Encrypted Session
เมื่อ SSH Client เชื่อมต่อกับ Device Client และ Server จะทำการ Negotiation เกี่ยวกับ Cryptographic Parameters ก่อนเข้าสู่กระบวนการ Authentication และสร้าง Secure Session
SSH Server บน Cisco คืออะไร?
เมื่อ Cisco Device ถูก Configure ให้รองรับ SSH ตัวอุปกรณ์สามารถรับ SSH Connection จาก Authorized Management Client ผ่าน VTY
Admin PC
10.10.10.100
|
| SSH
v
Cisco Router
10.10.10.1
ภาค 3: SSH กับ Telnet
SSH กับ Telnet ต่างกันอย่างไร?
| หัวข้อ | SSH | Telnet |
|---|---|---|
| Remote CLI | รองรับ | รองรับ |
| Encryption | มี | ไม่มีการเข้ารหัส Session แบบ SSH |
| Port โดยทั่วไป | TCP 22 | TCP 23 |
| เหมาะกับ Production Management | ใช่ เมื่อ Harden อย่างเหมาะสม | ควรหลีกเลี่ยง |
ทำไม Telnet จึงไม่ควรใช้กับ Production Network?
Telnet ไม่ให้ Confidentiality สำหรับ Session แบบที่ SSH ทำ
Telnet
Admin -------- Network -------- Device
Traffic
=
Not protected like SSH
ในขณะที่:
SSH
Admin ===== Encrypted Channel ===== Device
SSH ใช้ Port อะไร?
SSH โดยทั่วไปใช้ TCP Port 22
SSH Client
|
| TCP 22
v
SSH Server
ดังนั้นหาก Ping Device ได้ แต่ SSH ไม่ได้ ต้องตรวจ TCP/22, ACL, Firewall และ SSH Configuration เพิ่มเติม
ภาค 4: สิ่งที่ต้องมีก่อนเปิด SSH บน Cisco
องค์ประกอบพื้นฐาน
Cisco IOS/IOS XE Configuration แบบดั้งเดิมมักประกอบด้วย:
IP Connectivity
|
v
Hostname
|
v
Domain Name
|
v
RSA Key
|
v
User / AAA
|
v
VTY
|
v
SSH
Syntax และ Cryptographic Capability อาจแตกต่างกันตาม Platform, IOS/IOS XE Release และ Security Policy
Hostname และ Domain Name
ตัวอย่าง:
hostname R1
ip domain-name techerest.example
บน Cisco IOS แบบดั้งเดิม Hostname และ Domain Name ถูกใช้เป็นส่วนหนึ่งของกระบวนการ สร้าง RSA Key
techerest.example
ในตัวอย่างใช้เพื่อการศึกษา
โดย .example
เหมาะสำหรับ Documentation และ Lab
ไม่ใช่ Production Domain จริง
ภาค 5: RSA Key และ SSH
RSA Key คืออะไร?
RSA เป็น Public-Key Cryptography ที่ Cisco IOS/IOS XE หลาย Platform รองรับสำหรับ SSH Host Key
แนวคิด:
SSH Server
|
+---- Private Key
|
+---- Public Key
|
v
SSH Client
สร้าง RSA Key บน Cisco
ตัวอย่าง:
crypto key generate rsa modulus 2048
หลังสร้าง Key สามารถตรวจ SSH Status ตาม Platform ที่ใช้งาน
ลบ RSA Key ต้องระวัง
การลบ Host Key อาจทำให้ SSH Service ไม่สามารถใช้งานได้ จนกว่าจะสร้าง Key ใหม่
จึงไม่ควรทดลองลบ Key บน Production Device โดยไม่มี Recovery Access
ภาค 6: Local User และ Authentication
สร้าง Local User
ตัวอย่าง:
username netadmin privilege 15 secret STRONG_SECRET
ควรใช้ secret แทนรูปแบบ Password Storage ที่อ่อนแอกว่าเมื่อ Platform รองรับ
Local Authentication
สำหรับ Lab ขนาดเล็ก สามารถใช้ Local Database:
line vty 0 4
login local
transport input ssh
Flow:
SSH Client
|
v
Cisco Device
|
v
Local User Database
|
+---- Accept
|
+---- Reject
ภาค 7: VTY Line
VTY คืออะไร?
VTY หรือ Virtual Terminal Line ใช้รองรับ Remote CLI Session บน Cisco IOS/IOS XE
ตัวอย่าง:
line vty 0 4
หมายถึงกำลัง Configure กลุ่ม VTY Lines ตามช่วงที่ระบุ
อนุญาตเฉพาะ SSH
line vty 0 4
transport input ssh
คำสั่งนี้ช่วยปิดการรับ Remote Protocol อื่นบน VTY ที่ไม่ได้ระบุ เช่น Telnet
ภาค 8: SSH Version
SSH Version 2
Cisco IOS/IOS XE หลายรุ่น รองรับการกำหนด:
ip ssh version 2
ควรใช้ SSH Version 2 แทน SSH Version 1 ซึ่งล้าสมัยและไม่ควรถูกใช้ ใน Secure Management Design
ภาค 9: Cisco SSH Basic Lab
Topology
Admin PC
10.10.10.100
|
|
| SSH
|
v
+-----------+
| R1 |
|10.10.10.1 |
+-----------+
Step 1 — Configure Hostname
configure terminal
hostname R1
Step 2 — Configure Domain Name
ip domain-name techerest.example
Step 3 — สร้าง Local Administrator
username netadmin privilege 15 secret STRONG_SECRET
Step 4 — Generate RSA Key
crypto key generate rsa modulus 2048
Step 5 — ใช้ SSH Version 2
ip ssh version 2
Step 6 — Configure VTY
line vty 0 4
login local
transport input ssh
Step 7 — ทดสอบ SSH
จาก Client:
ssh netadmin@10.10.10.1
Configuration Overview
hostname R1
ip domain-name techerest.example
username netadmin privilege 15 secret STRONG_SECRET
crypto key generate rsa modulus 2048
ip ssh version 2
line vty 0 4
login local
transport input ssh
ภาค 10: SSH ทำงานร่วมกับ AAA อย่างไร?
SSH กับ AAA ทำหน้าที่คนละส่วน
SSH
=
Secure Transport
AAA
=
Authentication
Authorization
Accounting
เมื่อทำงานร่วมกัน:
Administrator
|
| SSH
v
Cisco Device
|
| AAA
v
TACACS+ / RADIUS Server
ตัวอย่าง TACACS+ Authentication
aaa new-model
aaa authentication login VTY-AUTH group tacacs+ local
line vty 0 4
login authentication VTY-AUTH
transport input ssh
แนวคิดคือ:
SSH
|
v
VTY
|
v
AAA Method List
|
+---- TACACS+
|
+---- Local Fallback
ภาค 11: จำกัด SSH ด้วย ACL
ทำไมต้องจำกัด Source ของ SSH?
แม้ SSH จะเข้ารหัส Traffic แต่ไม่ควรเปิด Management Access ให้ทุก Network เข้าถึงได้
ตัวอย่าง Policy:
Management VLAN
10.10.10.0/24
|
| SSH Allowed
v
Router / Switch
Guest VLAN
10.20.20.0/24
|
X
Router / Switch
สร้าง Standard ACL
ip access-list standard SSH-MANAGEMENT
permit 10.10.10.0 0.0.0.255
ผูก ACL กับ VTY
line vty 0 4
access-class SSH-MANAGEMENT in
transport input ssh
จากนั้นเฉพาะ Source ที่ตรงกับ ACL จึงสามารถเข้าถึง VTY ตาม Policy
ภาค 12: Management Source Network
ควรให้ SSH มาจาก Network ไหน?
Enterprise Network ควรพิจารณา Dedicated Management Network แทนการเปิด SSH จาก User VLAN ทุก Segment
Admin PC
|
v
Management VLAN
|
v
Management Firewall / ACL
|
v
Router / Switch
Management VLAN
ตัวอย่าง:
VLAN 99
Management
10.99.0.0/24
จากนั้นอนุญาต SSH เฉพาะ Management Subnet
ip access-list standard SSH-MANAGEMENT
permit 10.99.0.0 0.0.0.255
Out-of-Band Management
Network ที่มี Requirement สูง อาจใช้ Out-of-Band Management แยกจาก Production Data Plane
Production Network
==============================
Management Network
Admin ---- Console Server ---- Devices
ช่วยให้มี Recovery Path ในบาง Failure Scenario ที่ Production Network ไม่สามารถใช้งานได้
ภาค 13: Session Timeout และ Login Protection
ทำไมต้องมี Session Timeout?
ถ้า Administrator เปิด SSH Session ทิ้งไว้โดยไม่ได้ใช้งาน อาจเพิ่มความเสี่ยง โดยไม่จำเป็น
ตัวอย่าง VTY:
line vty 0 4
exec-timeout 10 0
ตัวอย่างนี้กำหนด Idle EXEC Timeout ประมาณ 10 นาที ตามพฤติกรรมของ Platform
จำกัด Login Attempt
Cisco IOS/IOS XE บาง Platform รองรับ Login Enhancement เช่น:
login block-for 120 attempts 3 within 60
แนวคิด:
Repeated Login Failures
|
v
Detection
|
v
Temporary Login Blocking
ภาค 14: SSH Verification
ตรวจ SSH Status
show ip ssh
ตรวจ SSH Sessions
บน Platform ที่รองรับ:
show ssh
ตรวจ RSA Keys
คำสั่งอาจแตกต่างตาม Platform เช่น:
show crypto key mypubkey rsa
ตรวจ VTY Configuration
show running-config | section line vty
ตรวจ Local User
show running-config | include username
ตรวจ ACL
show access-lists SSH-MANAGEMENT
ตรวจ AAA
show running-config | section aaa
ตรวจ IP Interface
show ip interface brief
ตรวจ Routing
show ip route
ภาค 15: SSH Troubleshooting
SSH Troubleshooting Workflow
Physical / Link
|
v
IP Address
|
v
Routing
|
v
Ping
|
v
TCP 22
|
v
SSH Service
|
v
VTY
|
v
ACL
|
v
Authentication
|
v
AAA
|
v
Authorization
ปัญหา 1 — Ping ได้แต่ SSH ไม่ได้
Ping ใช้ ICMP ส่วน SSH ใช้ TCP/22 โดยทั่วไป
Ping
=
ICMP
SSH
=
TCP 22
ตรวจ:
show ip ssh
show running-config | section line vty
show access-lists
Firewall
TCP 22
ปัญหา 2 — Connection Refused
อาจตรวจ:
SSH Enabled?
RSA / Host Key Exists?
VTY Allows SSH?
Correct IP?
TCP 22 Listening / Allowed?
ปัญหา 3 — Connection Timeout
ตรวจ:
Routing
ACL
Firewall
Management VRF
Return Path
Device Reachability
ปัญหา 4 — SSH เชื่อมต่อได้แต่ Login ไม่ผ่าน
แยกปัญหาออกจาก Transport:
TCP / SSH
=
Working
Authentication
=
Failing
ตรวจ:
Username
Credential
login local
AAA Method List
TACACS+ / RADIUS
Account Policy
ปัญหา 5 — Login ได้แต่ใช้ Command ไม่ได้
ปัญหาอาจอยู่ที่ Authorization ไม่ใช่ SSH
SSH
=
SUCCESS
Authentication
=
SUCCESS
Authorization
=
DENIED
ตรวจ:
Privilege Level
AAA Authorization
TACACS+ Policy
Command Authorization
ปัญหา 6 — SSH ใช้ได้จากบาง VLAN เท่านั้น
ตรวจ:
VTY access-class
Management ACL
Firewall
Routing
Source IP
VRF
ปัญหา 7 — SSH ใช้งานไม่ได้หลังเปลี่ยน ACL
ตรวจ ACL Hit และ Source Address ของ Administrator
show access-lists SSH-MANAGEMENT
ถ้ามี Existing Session อย่าปิด Session นั้น จนกว่าจะยืนยันว่า Configuration ใหม่ใช้งานได้
ปัญหา 8 — SSH Client เตือน Host Key Changed
คำเตือนนี้ไม่ควรถูก Ignore โดยอัตโนมัติ
อาจเกิดจาก:
Device Replaced
RSA Key Regenerated
Configuration Rebuilt
IP Reassigned
or
Possible Security Issue
ภาค 16: SSH Hardening บน Cisco
1. ปิด Telnet
line vty 0 4
transport input ssh
2. ใช้ SSH Version 2
ip ssh version 2
3. จำกัด Management Source
line vty 0 4
access-class SSH-MANAGEMENT in
4. ใช้ AAA
SSH
|
v
AAA
|
+---- Authentication
+---- Authorization
+---- Accounting
5. ใช้ Local Emergency Account อย่างมีการควบคุม
Local Emergency Credential ควรถูกเก็บอย่างปลอดภัย และใช้เมื่อ Central AAA ไม่สามารถใช้งานได้ ตาม Recovery Procedure
6. ตั้ง Idle Timeout
exec-timeout 10 0
7. ใช้ Management Network
User VLAN
|
X
SSH Management
Management VLAN
|
v
SSH Management
8. ใช้ Strong Cryptographic Policy
SSH Cryptographic Algorithms ที่รองรับแตกต่างกันตาม Cisco Platform และ Software Release
ควรปิด Legacy Algorithm เมื่อ Platform รองรับ และกำหนด Policy ตาม Security Standard ขององค์กร
9. ใช้ Logging และ Accounting
SSH Login
|
v
AAA Accounting
|
+
|
Syslog
|
v
Central Audit
10. Synchronize ด้วย NTP
เพื่อให้ Login, Accounting และ Syslog มี Timestamp ที่สัมพันธ์กัน
ภาค 17: Secure Management Architecture
รวม SSH, AAA, NTP, Syslog และ SNMP
Management Network
|
+------+------+
| |
Admin PC NMS
| |
| SSH | SNMP
v v
+-----------------------+
| Router / Switch |
+-----------+-----------+
|
+---------------+---------------+
| | |
v v v
AAA Server Syslog Server NTP Server
| | |
v v v
Identity Audit Time
แต่ละ Protocol มีหน้าที่ต่างกัน:
| ระบบ | หน้าที่ |
|---|---|
| SSH | Secure Remote Management |
| AAA | Authentication, Authorization, Accounting |
| SNMP | Monitoring และ Management Data |
| Syslog | Event Logging |
| NTP | Time Synchronization |
| DNS | Name Resolution |
Defense in Depth
การเปิด SSH ไม่ได้หมายความว่า Management Plane ปลอดภัยโดยอัตโนมัติ
ควรใช้หลาย Control ร่วมกัน:
Management VLAN
|
v
Firewall / ACL
|
v
SSH
|
v
AAA
|
v
Authorization
|
v
Accounting
|
v
Syslog
|
v
Monitoring
ภาค 18: ตัวอย่าง Secure Remote Management Design
Scenario: Enterprise Network
องค์กรมี:
2 Core Switches
10 Distribution Switches
100 Access Switches
4 Routers
Network Administrators
ไม่ควรเปิด SSH จากทุก User VLAN ไปยังอุปกรณ์เหล่านี้โดยตรง
Design ที่เหมาะสมกว่า:
Administrator
|
v
Management Workstation
|
v
Management VLAN
|
v
Firewall / ACL
|
v
Network Devices
|
+---- SSH
|
+---- TACACS+
|
+---- Syslog
|
+---- SNMP
|
+---- NTP
ตัวอย่าง Policy
Users VLAN
|
X
Device SSH
Guest VLAN
|
X
Device SSH
Server VLAN
|
X
Device SSH
Management VLAN
|
v
Device SSH
แนวทางนี้ช่วยลด Management Plane Exposure และทำให้ Access Policy ชัดเจนขึ้น
ภาค 19: SSH Best Practices
1. ใช้ SSH แทน Telnet
Telnet ไม่เหมาะกับ Secure Production Management
2. จำกัด SSH Source
อนุญาตเฉพาะ Management Network หรือ Authorized Hosts
3. ใช้ AAA สำหรับ Enterprise
ช่วยให้บริหาร Authentication, Authorization และ Accounting จากส่วนกลาง
4. ใช้ Local Account สำหรับ Emergency Access ตาม Policy
แต่ไม่ควรใช้ Shared Local Admin เป็น Daily Account ของ Administrator ทุกคน
5. ใช้ Individual Accounts
Admin-A
Admin-B
Admin-C
ดีกว่า:
admin
=
Shared by everyone
เพราะช่วยให้ Audit ระบุผู้ใช้งานได้ชัดเจนขึ้น
6. ใช้ NTP
เพื่อให้ SSH Login, AAA Accounting และ Syslog มี Timestamp ที่สอดคล้องกัน
7. ใช้ Central Syslog
เก็บ Management Event ไว้ภายนอก Device เพื่อช่วยในการ Audit และ Incident Investigation
8. ตรวจ SSH Algorithm Policy
เมื่อ Upgrade IOS/IOS XE ควรตรวจว่ามี Algorithm รุ่นเก่า ที่สามารถปิดได้หรือไม่ และตรวจ Compatibility กับ SSH Client
9. Backup Configuration ก่อนเปลี่ยน Management Access
โดยเฉพาะการแก้:
AAA
VTY
ACL
SSH Keys
Management VRF
Routing
10. ทดสอบด้วย Session ใหม่ก่อนปิด Session เดิม
Existing SSH Session
|
| Keep Open
|
+------------------+
|
New SSH Session
|
Test Changes
|
+--------+--------+
| |
Success Failure
| |
v v
Continue Rollback
ภาค 20: คำถามที่พบบ่อย
SSH ย่อมาจากอะไร?
Secure Shell
SSH ใช้ Port อะไร?
โดยทั่วไปใช้ TCP Port 22
Telnet ใช้ Port อะไร?
โดยทั่วไปใช้ TCP Port 23
ทำไม SSH ปลอดภัยกว่า Telnet?
SSH มี Cryptographic Protection สำหรับ Session ขณะที่ Telnet ไม่มีการป้องกัน Management Session แบบเดียวกัน
RSA Key ใช้ทำอะไรกับ SSH?
RSA สามารถใช้เป็น SSH Host Key บน Cisco Platform ที่รองรับ เพื่อเป็นส่วนหนึ่งของ Server Authentication และ Cryptographic Negotiation
SSH กับ AAA เหมือนกันหรือไม่?
ไม่เหมือนกัน
SSH
=
Secure Transport
AAA
=
Identity
Access Control
Accounting
เปิด SSH แล้วต้องใช้ ACL อีกหรือไม่?
ควรพิจารณาใช้ เพราะ Encryption ไม่ได้หมายความว่า ทุก Source ควรได้รับสิทธิ์ เชื่อมต่อ Management Plane
ควรเปิด SSH จาก Internet โดยตรงหรือไม่?
โดยทั่วไปควรลด Direct Exposure ของ Network Management Interface ต่อ Internet และใช้ Architecture เช่น VPN, Bastion/Jump Host, Management Network หรือ Out-of-Band Management ตาม Security Requirement
ทำไม Ping ได้แต่ SSH ไม่ได้?
เพราะ Ping และ SSH ใช้ Protocol ต่างกัน
Ping
=
ICMP
SSH
=
TCP 22
ทำไม SSH Login ได้แต่ Configure ไม่ได้?
SSH Transport และ Authentication อาจทำงานแล้ว แต่ Authorization หรือ Privilege อาจไม่อนุญาตให้ใช้ Command ดังกล่าว
ควรใช้ Local User หรือ TACACS+?
สำหรับ Lab หรือระบบขนาดเล็ก Local Authentication อาจเพียงพอ แต่ Enterprise Network มักได้รับประโยชน์จาก Centralized AAA และใช้ Local Account เป็น Recovery Method ตาม Security Policy
บทสรุป
SSH เป็นพื้นฐานสำคัญของ Secure Remote Management สำหรับ Router, Switch และ Network Infrastructure
องค์ประกอบพื้นฐาน:
IP Connectivity
|
v
SSH Server
|
v
Host Key
|
v
VTY
|
v
Authentication
|
v
Encrypted Management Session
แต่ Production Security ไม่ควรหยุดเพียงการเปิด SSH
ควรสร้าง Defense in Depth:
Management Network
|
v
ACL / Firewall
|
v
SSH
|
v
AAA
|
v
Authorization
|
v
Accounting
|
v
Syslog
|
v
Monitoring
และ Infrastructure Services ที่เรียนมาต่อเนื่องกันสามารถมองได้เป็น:
DNS
|
v
Name Resolution
NTP
|
v
Time Synchronization
Syslog
|
v
Event Logging
SNMP
|
v
Network Monitoring
AAA
|
v
Identity & Access Control
SSH
|
v
Secure Remote Management
เมื่อ Management Channel ถูกสร้างอย่างปลอดภัยแล้ว ขั้นต่อไปคือการนำ Security Controls ทั้งหมดมารวมเป็น Device Hardening Standard สำหรับ Router และ Switch
บทความถัดไป: Cisco Device Hardening สำหรับ Network Engineer: Secure Management, AAA, SSH, ACL, SNMP, NTP, Syslog และ Security Best Practices
Share your thoughts here
Join the conversation and share your perspective on this article.