交换机管理从 Telnet 换成 SSH 是基本安全要求,配置流程各家类似:开 SSH 服务、生成密钥对、建管理用户、VTY 线路绑定协议。这里给华为和思科两套可直接抄的配置。

华为 VRP(S 系列为例)

  • rsa local-key-pair create 生成密钥对(或 stelnet server enable 开启 SSH 服务)。
  • aaa 下建用户:local-user netadmin password cipher 你的密码 privilege level 15,local-user netadmin service-type ssh。
  • ssh user netadmin authentication-type password 绑定认证方式。
  • VTY 线路:user-interface vty 0 4 里 authentication-mode aaa 加 protocol inbound ssh。

思科 IOS

  • hostname Switch 和 ip domain-name lab.local(生成密钥的前提)。
  • crypto key generate rsa,选 2048 位以上。
  • username netadmin privilege 15 secret 密码。
  • VTY:line vty 0 4 下 transport input ssh 加 login local,全局 ip ssh version 2。

验证

从电脑 ssh netadmin@交换机IP 登录测试,华为设备可 display ssh server status 确认服务与版本。建议:配完顺手把 VTY 的 Telnet 关掉(transport input 只留 ssh),并设置空闲超时自动登出。