一、华为交换机SSH配置命令
在开始配置SSH之前,需要确认设备已经支持SSH功能。使用display version命令查看设备版本,确认是否支持SSH。SSH在版本小于VRP3.10-61xx.UP0时不被支持。
display version
配置SSH需要用到以下几个命令:
1. rsa local-key-pair # 生成本地公私钥对 2. ssh user xxxx authentication-type publickey # 添加SSH用户及指定公钥 3. ssh user xxxxxxxx service-type stelnet # 添加SSH用户的协议 4. user-interface vty 0 4 # 进入vty终端 5. authentication-mode aaa # 认证方式为AAA 6. protocol inbound ssh # 允许SSH协议登录
二、华为交换机SSH的几种模式
华为交换机支持的SSH模式有3种,分别是SSHv1、SSHv2和SSHv2 ACL。
SSHv1模式是老旧的SSH认证协议,不被推荐使用。SSHv2是新版的SSH认证协议,支持连接版IPv6地址,安全可靠。SSHv2 ACL是对SSHv2的进一步扩展,允许管理员通过访问控制列表来限制特定SSH用户的访问权限。
三、华为交换机SSH配置
下面是示例配置代码,用于配置一个SSH用户”gigawatt”,并限制其只能通过SSHv2协议进行登录,同时限制其只能登录VLAN 10所属的设备:
[Switch]rsa local-key-pair The key modulus size is 1024 bits. % Generating key ... Info: The operation will generate a new key pair. The old one will be removed! Are you sure to continue? [Y/N]:y [Switch]ssh user gigawatt authentication-type publickey [Switch-aaa]ssh user gigawatt service-type ssh // 允许SSH登录 [Switch-aaa]user-interface vty 0 4 [Switch-line-vty0-4]authentication-mode scheme [Switch-line-vty0-4]protocol inbound ssh // 允许SSH协议登录 [Switch-line-vty0-4]user privilege level 3 // 以3级权限登录 [Switch-line-vty0-4]acl acl-number 2001 inbound // 设置访问控制列表,限制用户登录VLAN 10 [Switch-acl-basic-2001]rule permit vlan-id 10 // 允许vlan-id 10,拒绝其它vlan-id [Switch-acl-basic-2001]rule deny 0 // 拒绝其它用户
四、华为交换机SSH远程登录配置命令
在远程登录交换机之前,需要确认远程服务器上已安装SSH客户端软件(如PuTTY)。
要通过SSH远程连接交换机,需要知道交换机的IP地址和登录SSH的用户名。配置命令如下:
ssh gigawatt@192.168.1.1
五、华为交换机SSH登录命令
以下是SSH登录交换机的命令:
ssh gigawatt@192.168.1.1
六、华为交换机SSH密钥配置
SSH使用密钥来进行认证。在远程登录SSH时需要通过密钥来验证身份。密钥的生成可以使用下列命令:
ssh-keygen -t rsa
七、华为交换机SSH配置实例
下面是一个实际的SSH配置示例,允许用户”gigawatt”通过SSHv2协议登录交换机,并限制其只能访问VLAN 10。同时,将另一个用户”hacker”被禁止访问交换机:
[Switch]rsa local-key-pair [Switch]ssh user gigawatt authentication-type publickey [Switch-aaa]ssh user gigawatt service-type ssh [Switch-aaa]user-interface vty 0 4 [Switch-line-vty0-4]authentication-mode scheme [Switch-line-vty0-4]protocol inbound ssh [Switch-line-vty0-4]user privilege level 3 [Switch-line-vty0-4]acl acl-number 2001 inbound // 限制用户仅能登录VLAN 10 [Switch-acl-basic-2001]rule permit vlan-id 10 [Switch-acl-basic-2001]rule deny 0 // 拒绝其它vlan-id [Switch-aaa]int ip vpn-instance mgmt [Switch-aaa-ip-vpn-mgmt]quit [Switch-aaa]int radius scheme-default [Switch-aaa-radius-default]server 192.168.7.100 [Switch-aaa-radius-default]key authentication radius-key [Switch-aaa-radius-default]quit [Switch-aaa]domain giga.com.cn [Switch-aaa-domain-giga.com.cn]authentication-scheme default [Switch-aaa-domain-giga.com.cn]quit [Switch-aaa]local-user hacker service-type ssh //禁止用户hacker访问SSH [Switch-aaa]aaa
八、华为交换机SSH指定端口
可以通过指定端口号来将SSH服务映射到不同的端口(如2222)。
ssh-gigawatt@192.168.1.1 -p 2222
原创文章,作者:小蓝,如若转载,请注明出处:https://www.506064.com/n/195709.html