004-配置交换机ssh远程登录

配置交换机ssh远程登录

注意事项

  1. 要远程的本机电脑必须与该交换机在同一个网段,以下实验在172.16.12段下模拟,本地ip设置为172.16.12.10,交换机的ip设置为172.16.12.254

  2. 将密码设置为明文(simple)是不安全的,因此建议使用 cipher 关键字来加密密码。

  3. 在H3C网络设备的命令行接口(CLI)中,[H3C-line-vty0-4]user privilege level <0-15> 命令用于设置通过VTY(Virtual Teletype)接口登录的用户所拥有的权限级别。权限级别决定了用户能够执行哪些命令和操作。

    <0-15> 是一个范围,表示用户权限级别的可能值。不同的级别对应不同的权限。一般来说,级别越高,用户能够执行的命令就越多,权限也就越大。

    • 级别0:通常是访客级别,用户只能执行一些基本的查看命令,不能修改配置。
    • 级别3:通常是普通用户级别,用户能够执行一些基本的配置命令,但可能无法访问一些高级功能或命令。
    • 级别15:通常是管理员级别,用户能够执行所有命令,拥有完全的控制权。

    以下是一个设置用户权限级别的示例:

    bash 复制代码
    [H3C]user-interface vty 0 4  
    [H3C-ui-vty0-4]user privilege level 15

    或者,在某些H3C设备上,可能需要使用line vty 0 4命令来进入配置模式,并设置权限级别:

    bash 复制代码
    [H3C]line vty 0 4  
    [H3C-line-vty0-4]user privilege level 15

    设置完成后,通过VTY接口登录的用户将拥有指定的权限级别。请注意,设置过高的权限级别可能会带来安全风险,因为拥有高级权限的用户能够执行更多的命令和操作,包括可能更改设备的配置或执行其他可能影响网络安全的操作。因此,在设置用户权限级别时,应该根据实际需要和安全性考虑来选择合适的级别。

拓扑图

交换配置如下

  • 配置交换机管理地址
shell 复制代码
<H3C>sys
System View: return to User View with Ctrl+Z.
[H3C]
[H3C]interface vlan 1
[H3C-Vlan-interface1]ip address 172.16.12.254 24
[H3C-Vlan-interface1]
[H3C-Vlan-interface1]quit
[H3C]
  • 开启ssh服务,修改ssh服务的端口号
shell 复制代码
[H3C]ssh server enable 
[H3C]ssh server port 54321
  • 创建秘钥
shell 复制代码
[H3C]public-key local create rsa #创建rsa秘钥,推荐使用rsa
The local key pair already exists.
Confirm to replace it? [Y/N]:y
The range of public key modulus is (512 ~ 4096). 
If the key modulus is greater than 512, it will take a few minutes.
Press CTRL+C to abort.
Input the modulus length [default = 1024]:
Generating Keys...
.
Create the key pair successfully.
[H3C]
[H3C]public-key local create dsa #创建dsa秘钥
The range of public key modulus is (512 ~ 2048). 
If the key modulus is greater than 512, it will take a few minutes.
Press CTRL+C to abort.
Input the modulus length [default = 1024]:
Generating Keys...
.
Create the key pair successfully.
[H3C]
  • 创建ssh用户密码
shell 复制代码
[H3C]local-user admin #创建用户admin
New local user added.
[H3C-luser-manage-admin]
[H3C-luser-manage-admin]password simple Huawei@123 #设置密码为 Huawei@123
[H3C-luser-manage-admin]%Jun 10 20:41:11:926 2024 H3C LS/5/LS_PWD_CHGPWD: The password of local device-management user admin was modified.

[H3C-luser-manage-admin]authorization-attribute user-role network-admin #设置用户级别network-admin管理级
[H3C-luser-manage-admin]
[H3C-luser-manage-admin]service-type ssh #设置用户登录权限为ssh
[H3C-luser-manage-admin]quit
  • 配置ssh用户密码
shell 复制代码
[H3C]user-interface vty 0 4 #配置vty为0-4 最多允许0到4个用户同时登录访问
[H3C-line-vty0-4]
[H3C-line-vty0-4]authentication-mode scheme #设置认证模式为scheme
[H3C-line-vty0-4]
[H3C-line-vty0-4]protocol inbound ssh #设置登录协议为ssh
[H3C-line-vty0-4]quit
[H3C]save #保存
The current configuration will be written to the device. Are you sure? [Y/N]:y
Please input the file name(*.cfg)[flash:/startup.cfg]
(To leave the existing filename unchanged, press the enter key):
Validating file. Please wait...
Saved the current configuration to mainboard device successfully.
[H3C]

使用Xshell测试连接

  • 协议:ssh
  • 主机:配置的交换机管理地址(172.16.12.254)
  • 端口号:配置交换机ssh服务的端口号(54321)
  • 填写用户身份验证
  • 用户名:交换机ssh登录的用户名(admin)
  • 密码:交换机ssh登录的密码(Huawei@123)

Xshell用ssh连接交换机成功

相关推荐
骇客野人4 小时前
Redis 完整安装部署方案(Linux,分【源码编译】+【Docker】两种,推荐生产用源码,测试快速用 Docker)
运维
比兔代理6 小时前
正向代理与反向代理技术辨析,为什么代理 IP 属于正向代理
服务器·网络·http·ip
蓝速科技7 小时前
会议室门牌公告通知发布选型与落地指南丨蓝速科技
大数据·运维·数据库·人工智能·科技
Ivanqhz7 小时前
SVD++算法
java·服务器·网络·深度学习·神经网络
chicheese8 小时前
Linux 面试速查表:从初级到高级,附高频场景答题模板
linux·运维
Linux-lucky8 小时前
32-38-Linux学习之旅之MySQL综合
linux·运维·学习·mysql·ubuntu
智能运维指南9 小时前
2026年ITSM系统怎么选?四款主流方案与五维评估模型
运维·itsm·嘉为蓝鲸
我命由我123459 小时前
Git 推送报错:error: src refspec main does not match any
运维·git·gitee·github·运维开发·学习方法·版本控制
骇客野人9 小时前
测试环境MySQL迁移Vastbase(海量数据库)完整改造与落地实施方案
运维·服务器
迪康Defender10 小时前
终端安全实战:如何高效解决企业U盘泄密与管控难题
运维·网络·安全·web安全·终端安全管理