From 5f7a12dbb5bb68d5f4df67b574fc3e62482c6357 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=91=E7=A2=A7=E4=BB=99?= Date: Mon, 31 Mar 2025 22:14:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=A4=E6=8D=A2=E6=9C=BA=E5=AE=89=E5=85=A8?= =?UTF-8?q?=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...41\347\220\206\351\205\215\347\275\256.md" | 155 ++++++++++++++++++ 1 file changed, 155 insertions(+) create mode 100644 "20 \351\203\221\347\242\247\344\273\231/20250331 \344\272\244\346\215\242\346\234\272\345\256\211\345\205\250\347\256\241\347\220\206\351\205\215\347\275\256.md" diff --git "a/20 \351\203\221\347\242\247\344\273\231/20250331 \344\272\244\346\215\242\346\234\272\345\256\211\345\205\250\347\256\241\347\220\206\351\205\215\347\275\256.md" "b/20 \351\203\221\347\242\247\344\273\231/20250331 \344\272\244\346\215\242\346\234\272\345\256\211\345\205\250\347\256\241\347\220\206\351\205\215\347\275\256.md" new file mode 100644 index 0000000..2f05204 --- /dev/null +++ "b/20 \351\203\221\347\242\247\344\273\231/20250331 \344\272\244\346\215\242\346\234\272\345\256\211\345\205\250\347\256\241\347\220\206\351\205\215\347\275\256.md" @@ -0,0 +1,155 @@ +### **交换机安全管理配置步骤** + +#### **步骤 1:设置 Console 密码** +- **目的**:防止未经授权的人员通过物理控制台接口操作交换机。 + + ```cmd + Switch> enable + Switch# configure terminal + Switch(config)# line console 0 + Switch(config-line)# password yourConsolePassword + Switch(config-line)# login + Switch(config-line)# end + Switch# write + ``` + +#### **步骤 2:设置特权模式密码** +- **目的**:增加设备的安全性,防止未经授权的用户进入特权模式。 + + ```cmd + Switch> enable + Switch# configure terminal + Switch(config)# enable secret yourEnablePassword + Switch(config)# end + Switch# write + ``` + +#### **步骤 3:配置管理 IP 地址** +- **目的**:为交换机配置管理 IP 地址,以便通过网络进行远程管理。 + + ```cmd + Switch> enable + Switch# configure terminal + Switch(config)# interface vlan 1 + Switch(config-if)# ip address 192.168.10.1 255.255.255.0 + Switch(config-if)# no shutdown + Switch(config-if)# end + Switch# write + ``` + +#### **步骤 4:配置 SSH** +- **目的**:通过 SSH 安全地远程管理交换机,优先使用 SSH 替代 Telnet。 + + ```cmd + Switch> enable + Switch# configure terminal + Switch(config)# hostname SW1 + Switch(config)# ip domain-name example.com + Switch(config)# crypto key generate rsa + Switch(config)# username admin secret yourSSHPassword + Switch(config)# line vty 0 4 + Switch(config-line)# transport input ssh + Switch(config-line)# login local + Switch(config-line)# end + Switch# write + ``` + +#### **步骤 5:(可选)配置 Telnet(不推荐)** +- **目的**:如果确实需要使用 Telnet,可以配置 Telnet,但建议仅在安全要求较低的环境中使用。 + + ```cmd + Switch> enable + Switch# configure terminal + Switch(config)# line vty 0 4 + Switch(config-line)# password yourTelnetPassword + Switch(config-line)# login + Switch(config-line)# transport input telnet + Switch(config-line)# end + Switch# write + ``` + +#### **步骤 6:启用密码加密** +- **目的**:对存储在配置文件中的密码进行加密,防止明文密码泄露。 +- **配置**: + ```cmd + Switch> enable + Switch# configure terminal + Switch(config)# service password-encryption + Switch(config)# end + Switch# write + ``` + +#### **步骤 7:查看配置** +- **目的**:检查配置是否生效,确保所有设置正确无误。 +- **配置**: + ```cmd + Switch> enable + Switch# show running-config + ``` + +练习清单: + +1. 分别完成Console密码,Telnet,SSH登录的实验 + + ![1](https://gitee.com/zheng-bixian/images/raw/master/图片/20250331191710864.PNG) + + ![2](https://gitee.com/zheng-bixian/images/raw/master/图片/20250331191732480.png) + + ![3](https://gitee.com/zheng-bixian/images/raw/master/图片/20250331191805444.png) + + ![5](https://gitee.com/zheng-bixian/images/raw/master/图片/20250331191900017.png)![4](https://gitee.com/zheng-bixian/images/raw/master/图片/20250331191848902.png) + + + +2. 如何同时开启SSH和Telnet + + ```cmd + Switch> enable // 进入特权模式 + Switch# configure terminal // 进入全局配置模式 + Switch(config)# line vty 0 4 // 进入VTY接口配置模式,配置5个并发远程连接 + Switch(config-line)# password yourTelnetPassword // 设置Telnet登录密码 + Switch(config-line)# login // 启用VTY接口的密码验证 + Switch(config-line)# transport input telnet ssh // 设置VTY接口接受Telnet和SSH连接 + Switch(config-line)# end // 退出VTY接口配置模式 + Switch# write // 保存配置 + ``` + +3. 如何反向操作,如取消密码,取消登录 + + #### **取消Console密码** + + ```cmd + Switch> enable // 进入特权模式 + Switch# configure terminal // 进入全局配置模式 + Switch(config)# line console 0 // 进入控制台接口配置模式 + Switch(config-line)# no password // 移除控制台接口的密码 + Switch(config-line)# no login // 禁用控制台接口的密码验证 + Switch(config-line)# end // 退出控制台接口配置模式 + Switch# write // 保存配置 + ``` + + #### **取消Telnet配置** + + ```cmd + Switch> enable // 进入特权模式 + Switch# configure terminal // 进入全局配置模式 + Switch(config)# line vty 0 4 // 进入VTY接口配置模式 + Switch(config-line)# no password // 移除VTY接口的密码 + Switch(config-line)# no login // 禁用VTY接口的密码验证 + Switch(config-line)# no transport input telnet // 禁用VTY接口的Telnet连接 + Switch(config-line)# end // 退出VTY接口配置模式 + Switch# write // 保存配置 + ``` + + #### **取消SSH配置** + + ```cmd + Switch> enable // 进入特权模式 + Switch# configure terminal // 进入全局配置模式 + Switch(config)# no username admin // 移除本地用户admin + Switch(config)# line vty 0 4 // 进入VTY接口配置模式 + Switch(config-line)# no transport input ssh // 禁用VTY接口的SSH连接 + Switch(config-line)# no login local // 禁用本地用户认证 + Switch(config-line)# end // 退出VTY接口配置模式 + Switch# write // 保存配置 + ``` \ No newline at end of file -- Gitee