一、配置准备工作
- 连接 Console 口:使用 Console 线将计算机与交换机的 Console 口相连,通信波特率设置为 9600。
- 进入系统视图并修改设备名称:
plaintext
<Huawei> system-view [Huawei] sysname SW1 # 将设备名称修改为SW1
-
-
二、SSH 配置步骤(推荐用于安全连接)
1. 生成 RSA 密钥对
用于加密 SSH 通信,默认密钥长度为 2048 位:
plaintext
[SW1] rsa local-key-pair create
2. 配置 VTY 用户界面
plaintext
[SW1] user-interface vty 0 4
[SW1-ui-vty0-4] authentication-mode aaa # 启用AAA认证方式
[SW1-ui-vty0-4] protocol inbound ssh # 仅允许SSH协议接入
3. 创建管理用户
plaintext
[SW1] aaa
[SW1-aaa] local-user admin password cipher Admin@123 # 设置用户名和加密密码
[SW1-aaa] local-user admin privilege level 3 # 权限等级3为最高权限
[SW1-aaa] local-user admin service-type ssh # 指定用户服务类型为SSH
4. 启用 SSH 服务
plaintext
[SW1] stelnet server enable # 开启STelnet服务
[SW1] ssh user admin authentication-type password # 设置用户认证方式为密码
三、Telnet 配置步骤(不推荐在生产环境使用)
1. 基础配置
plaintext
[SW1] telnet server enable # 开启Telnet服务
[SW1] user-interface vty 0 4
[SW1-ui-vty0-4] authentication-mode password # 启用密码认证
[SW1-ui-vty0-4] set authentication password cipher Telnet@123 # 设置加密的认证密码
2. 可选配置:ACL 限制(增强安全性)
plaintext
[SW1] acl 2000 # 创建基本ACL 2000
[SW1-acl-basic-2000] rule permit source 192.168.1.100 0 # 允许指定IP地址访问
[SW1-ui-vty0-4] acl 2000 inbound # 应用ACL到VTY界面,仅允许符合规则的IP访问
四、配置验证命令
1. 查看 SSH 状态
plaintext
display ssh server status # 查看SSH服务器状态
display ssh user-information # 查看SSH用户信息
2. 测试连接
- SSH 连接测试(客户端命令):
plaintext
ssh admin@交换机IP
- Telnet 连接测试(客户端命令):
plaintext
telnet 交换机IP
五、安全增强建议
- 禁用 SSH v1 版本,仅使用更安全的 v2:
plaintext
[SW1] ssh server compatible-ssh1x disable
- 修改默认 SSH 端口(默认 22,改为 2222 示例):
plaintext
[SW1] ssh server port 2222
- 设置空闲超时时间(5 分钟无操作自动断开连接):
plaintext
[SW1-ui-vty0-4] idle-timeout 5