• 产品与解决方案
  • 行业解决方案
  • 服务
  • 支持
  • 合作伙伴
  • 新华三人才研学中心
  • 关于我们

H3C S12500X-AF & S12500-X & S9800系列以太网交换机 典型配置举例-Release 27xx系列-6W100

目录

34-SSH典型配置举例

本章节下载 34-SSH典型配置举例  (814.43 KB)

docurl=/cn/Service/Document_Software/Document_Center/Home/Switches/00-Public/Configure/Typical_Configuration_Example/H3C_S12500X-AF_S12500-X_S9800_CE-6W100/201907/1212654_30005_0.htm

34-SSH典型配置举例

H3C S12500X-AF & S12500-X & S9800产品SSH配置举例

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

资料版本:6W100-20190628

 

Copyright © 2019 新华三技术有限公司 版权所有,保留一切权利。

非经本公司书面许可,任何单位和个人不得擅自摘抄、复制本文档内容的部分或全部,并不得以任何形式传播。

除新华三技术有限公司的商标外,本手册中出现的其它公司的商标、产品标识及商品名称,由各自权利人拥有。

本文档中的信息可能变动,恕不另行通知。

 



1  简介

本章介绍了使用SSH(Secure Shell,安全外壳)功能实现安全的远程访问或文件管理的典型配置举例。

2  配置前提

本文档中的配置均是在实验室环境下进行的配置和验证,配置前设备的所有参数均采用出厂时的缺省配置。如果您已经对设备进行了配置,为了保证配置效果,请确认现有配置和以下举例中的配置不冲突。

本文假设您已了解SSH特性。

3  使用限制

举例中的设备运行于非FIPS模式下。若设备运行于FIPS模式下:

·     相关的配置和显示信息会有所变化,请以设备的实际情况为准。

·     设备作为服务器仅支持RSA和ECDSA密钥对,且RSA密钥对的模数只能为2048比特。

4  设备作为Stelnet服务器配置举例(password认证)

4.1  组网需求

图1所示,网络管理员需要通过Internet远程登录到校园网的网关设备(Device)上对其进行相关配置。为了提高对Device进行管理的安全性,可将Device配置为Stelnet服务器,并在Host上运行Stelnet客户端软件,在二者之间建立SSH连接。要求:

·     Device通过SSH的password认证方式对客户端进行认证,认证过程在Device本地完成;

·     网络管理员Host的登录用户名为client001,密码为aabbcc,登录设备后可以正常使用所有命令。

图1 设备作为Stelnet服务器配置组网图

 

4.2  配置思路

·     为了使SSH的版本协商和算法协商过程正常运行,且为了保证客户端对连接的服务器的认证正常进行,请在服务器端生成RSA、DSA和ECDSA密钥对。

·     为了采用本地认证的方式认证用户,需要在本地服务器Device上创建相应的本地用户,并在本地用户视图下配置密码。

·     Stelnet客户端通过VTY用户线访问设备。因此,需要配置登录用户线的认证方式为scheme方式。

·     为了使Stelnet用户登录设备后能正常使用所有命令,将用户角色设置为network-admin,缺省情况下本地用户的用户角色为network-operator。

4.3  使用版本

本举例进行配置和验证所使用的版本,如表1所示。

表1 产品与软件版本适配关系

产品

软件版本

S12500X-AF系列交换机

S12500X-CMW710-R2712

S12500-X系列交换机

S12500X-CMW710-R2712

S9800系列交换机

S9800-CMW710-R2712

 

4.4  配置注意事项

缺省情况下,S12500X-AF系列、S12500-X系列、S9800系列交换机的接口处于ADM(Administratively Down)状态,请根据实际需要在对应接口视图下使用undo shutdown命令开启接口。

4.5  配置步骤

# 生成RSA密钥对。

<Device> system-view

[Device] public-key local create rsa

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.

# 生成DSA密钥对。

[Device] public-key local create 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.

# 生成ECDSA密钥对。

[Device] public-key local create ecdsa secp256r1

Generating Keys...

.

Create the key pair successfully.

# 使能SSH服务器功能。

[Device] ssh server enable

# 创建VLAN 2,并将Ten-GigabitEthernet1/0/2加入VLAN 2。

[Device] vlan 2

[Device-vlan2] port ten-gigabitethernet 1/0/2

[Device-vlan2] quit

# 配置VLAN接口2的IP地址,客户端将通过该地址连接Stelnet服务器。

[Device] interface vlan-interface 2

[Device-Vlan-interface2] ip address 192.168.1.40 255.255.255.0

[Device-Vlan-interface2] quit

# 设置Stelnet客户端登录用户界面的认证方式为scheme。

[Device] line vty 0 63

[Device-line-vty0-63] authentication-mode scheme

[Device-line-vty0-63] quit

# 创建本地用户client001,并设置用户密码、服务类型和用户角色。

[Device] local-user client001 class manage

New local user added.

[Device-luser-manage-client001] password simple aabbcc

[Device-luser-manage-client001] service-type ssh

[Device-luser-manage-client001] authorization-attribute user-role network-admin

[Device-luser-manage-client001] quit

4.6  验证配置

说明

Stelnet客户端软件有很多,例如PuTTY、OpenSSH等。本文中仅以客户端软件PuTTY0.60为例,说明Stelnet客户端的配置方法。

 

# 安装PuTTY0.60软件。

# 打开PuTTY.exe程序,点击“Session”功能区,出现如图2所示的客户端配置界面。

·     在“Host Name(or IP address)”文本框中输入Stelnet服务器的IP地址为192.168.1.40。

·     在“Port”文本框中输入SSH协议端口号22。

·     在“Connection type”区域选择SSH协议。

图2 Stelnet客户端配置界面

 

# 在图2界面中,单击<Open>按钮。弹出“PuTTY Security Alert”对话框。

图3 Stelnet客户端登录界面(一)

 

# 单击“是(Y)”按钮,并输入用户名“client001”和密码“aabbcc”,即可成功登录设备使用所有命令。

login as: client001

client001@192.168.1.40's password:

 

******************************************************************************

*Copyright (c) 2004-2018 New H3C Technologies Co., Ltd. All rights reserved.*

* Without the owner's prior written consent,                                 *

* no decompiling or reverse-engineering shall be allowed.                    *

******************************************************************************

 

<Device>

4.7  配置文件

#

vlan 2

#

interface Vlan-interface2

 ip address 192.168.1.40 255.255.255.0

#

interface Ten-GigabitEthernet1/0/2

 port link-mode bridge

 port access vlan 2

#

line vty 0 63

 authentication-mode scheme

#

ssh server enable

#

local-user client001 class manage

 password hash $h$6$CqMnWdX6LIW/hz2Z$4+0Pumk+A98VlGVgqN3n/mEi7hJka9fEZpRZIpSNi9b

cBEXhpvIqaYTvIVBf7ZUNGnovFsqW7nYxjoToRDvYBg==

 service-type ssh

 authorization-attribute user-role network-admin

 authorization-attribute user-role network-operator

#

5  设备作为Stelnet服务器配置举例(publickey认证)

5.1  组网需求

图4所示,网络管理员需要通过Internet远程登录到校园网的网关设备(Device)上对其进行相关配置。为了提高对Device进行管理的安全性和认证强度,将Device配置为Stelnet服务器,要求:

·     Device通过publickey认证方式对Stelnet客户端进行认证,使用的公钥算法为RSA。

·     网络管理员Host的登录用户名为client001,登录设备后可以正常使用所有命令。

·     服务器端通过从公钥文件中导入的方式来配置客户端的公钥。

图4 设备作为Stelnet服务器配置组网图

 

 

5.2  配置思路

·     在服务器的配置过程中需要指定客户端的公钥信息,因此需要首先完成客户端密钥对的配置,再进行服务器的配置。

·     服务器在采用publickey方式验证客户端身份时,首先要比较客户端发送的Stelnet用户名、主机公钥是否与本地配置的SSH用户名以及相应的客户端主机公钥一致,在确认用户名和客户端主机公钥正确后,再利用数字签名对客户端进行验证,而该签名是客户端利用主机公钥对应的私钥计算出的。因此,需要在服务器端配置客户端的RSA主机公钥,并在客户端为该SSH用户指定与主机公钥对应的RSA主机私钥。

·     如果SSH服务器采用publickey方式认证客户端,必须在服务器上创建相应的SSH用户,以及同名的本地用户(用于下发授权属性:工作目录、用户角色)。

·     Stelnet客户端通过VTY用户线访问设备。因此,需要配置登录用户线的认证方式为scheme方式。

·     为了使Stelnet用户登录设备后要能正常使用所有命令,将用户的用户角色设置为network-admin,缺省情况下本地用户的用户角色为network-operator。

5.3  使用版本

本举例进行配置和验证所使用的版本,如表2所示。

表2 产品与软件版本适配关系

产品

软件版本

S12500X-AF系列交换机

S12500X-CMW710-R2712

S12500-X系列交换机

S12500X-CMW710-R2712

S9800系列交换机

S9800-CMW710-R2712

 

5.4  配置注意事项

·     FIPS模式下,设备作为SSH服务器不支持publickey认证方式。

·     虽然一个客户端只会采用RSA、DSA或ECDSA公钥算法中的一种来认证服务器,但是由于不同客户端支持的公钥算法不同,为了确保客户端能够成功登录服务器,请在服务器上同时生成RSA、DSA和ECDSA密钥对。

·     缺省情况下,S12500X-AF系列、S12500-X系列、S9800系列交换机的接口处于ADM(Administratively Down)状态,请根据实际需要在对应接口视图下使用undo shutdown命令开启接口。

5.5  配置步骤

5.5.1  配置Host作为Stelnet客户端

说明

客户端软件有很多,例如PuTTY、OpenSSH等。本文中仅以客户端软件PuTTY0.60为例,说明Stelnet客户端的配置方法。

 

# 在客户端运行PuTTYGen.exe,在参数栏中选择“SSH-2 RSA”,点击<Generate>,产生客户端密钥对。

图5 生成客户端密钥(1)

 

# 在产生密钥对的过程中需不停地移动鼠标,鼠标移动仅限于图6蓝色框中除绿色标记进程条外的地方,否则进程条会停止显示,密钥对将停止产生。

图6 生成客户端密钥(2

# 密钥对产生后,点击<Save public key>,输入存储公钥的文件名key.pub,点击<保存>按钮将公钥文件保存在D盘。

图7 生成客户端密钥(3)

# 点击<Save private key>存储私钥,选择保存的路径(例如D:\),并输入私钥文件名为private.ppk,点击保存。

5.5.2  配置Device作为FTP服务器

# 创建VLAN 2,并将Ten-GigabitEthernet1/0/2加入VLAN 2。

<Device> system-view

[Device] vlan 2

[Device-vlan2] port ten-gigabitethernet 1/0/2

[Device-vlan2] quit

# 配置VLAN接口2的IP地址。

[Device] interface vlan-interface 2

[Device-Vlan-interface2] ip address 192.168.1.40 255.255.255.0

[Device-Vlan-interface2] quit

# 在Device上创建一个ftp类型的本地用户,并设置密码为明文ftp,服务类型为FTP,用户角色为network-admin,工作目录为flash:/。

[Device] local-user ftp class manage

New local user added.

[Device-luser-manage-ftp] password simple ftp

[Device-luser-manage-ftp] authorization-attribute user-role network-admin

[Device-luser-manage-ftp] authorization-attribute work-directory flash:/

[Device-luser-manage-ftp] service-type ftp

[Device-luser-manage-ftp] quit

# 开启Device 的FTP服务器功能。

[Device] ftp server enable

[Device] quit

5.5.3  配置FTP客户端上传公钥文件

# Host通过FTP登录并上传公钥文件key.pub到Device。

<Host>ftp 192.168.1.40

Press CTRL+C to abort.

Connected to 192.168.1.40 (192.168.1.40).

220 FTP service ready.

User (192.168.1.56:(none)): ftp

331 Password required for ftp.

Password:

230 User logged in.

Remote system type is UNIX.

Using binary mode to transfer files.

ftp> put flash:/key.pub

227 Entering Passive Mode (192,168,1,40,41,116)

150 Accepted data connection

226 File successfully transferred

301 bytes sent in 0.000 seconds (1.05 Mbytes/s)

ftp> quit

221-Goodbye. You uploaded 1 and downloaded 0 kbytes.

221 Logout.

5.5.4  配置Device作为Stelnet服务器

# 生成RSA密钥对。

[Device] public-key local create rsa

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.

# 生成DSA密钥对。

[Device] public-key local create 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.

# 生成ECDSA密钥对。

[Device] public-key local create ecdsa secp256r1

Generating Keys...

.

Create the key pair successfully.

# 使能SSH服务器功能。

[Device] ssh server enable

# 设置Stelnet客户端登录用户界面的认证方式为scheme。

[Device] line vty 0 63

[Device-line-vty0-63] authentication-mode scheme

[Device-line-vty0-63] quit

# 从文件key.pub中导入客户端的公钥,并命名为devicekey。

[Device] public-key peer devicekey import sshkey key.pub

# 设置SSH用户client001的认证方式为publickey,并指定公钥为devicekey。

[Device] ssh user client001 service-type stelnet authentication-type publickey assign publickey devicekey

# 创建本地用户client001,并设置服务类型为SSH,用户角色为network-admin。

[Device] local-user client001 class manage

New local user added.

[Device-luser-manage-client001] service-type ssh

[Device-luser-manage-client001] authorization-attribute user-role network-admin

[Device-luser-manage-client001] quit

5.6  验证配置

# 客户端打开PuTTY.exe程序,点击“Session”功能区,出现如图8所示的客户端配置界面。

·     在“Host Name(or IP address)”文本框中输入Stelnet服务器的IP地址为192.168.1.40。

·     在“Port”文本框中输入SSH协议端口号22。

·     在“Connection type”区域选择SSH协议。

图8 Stelnet客户端配置界面(1)

 

# 单击左侧导航栏“Connection->SSH”,出现如图9的界面。选择“Preferred SSH protocol version”为“2”。

图9 Stelnet客户端配置界面(2)

 

# 单击左侧导航栏“Connection->SSH”下面的“Auth”(认证),出现如图10的界面。单击<Browse…>按钮,弹出文件选择窗口。选择与配置到服务器端的公钥对应的私钥文件private.ppk。

图10 Stelnet客户端配置界面(3)

 

# 单击<Open>按钮。弹出“PuTTY Security Alert”对话框。

图11 Stelnet客户端登录界面(一)

 

# 单击“是(Y)”按钮,按提示输入用户名client001,即可进入Device的配置界面,用户角色为network-admin。

login as: client001

Authenticating with public key ”rsa-key-20140726”

 

******************************************************************************

* Copyright (c) 2004-2018 New H3C Technologies Co., Ltd. All rights reserved.*

* Without the owner's prior written consent,                                 *

* no decompiling or reverse-engineering shall be allowed.                    *

******************************************************************************

 

<Device>

5.7  配置文件

#

vlan 2

#

interface Vlan-interface2

 ip address 192.168.1.40 255.255.255.0

#

interface Ten-GigabitEthernet1/0/2

 port link-mode bridge

 port access vlan 2

#

line vty 0 63

 authentication-mode scheme

#

ssh server enable

ssh user client001 service-type stelnet authentication-type publickey assign publickey devicekey

#

local-user client001 class manage

service-type ssh

 authorization-attribute user-role network-operator

 authorization-attribute user-role network-admin

#

public-key peer Devicekey

public-key-code begin

30819D300D06092A864886F70D010101050003818B0030818702818100A2DBC1FD76A837BEF5D322598442D6753B2E8F7ADD6D6209C80843B206B309078AFE2416CB4FAD496A6627243EAD766D57AEA70B901B4B4566D9A651B133BAE34E9B9F04E542D64D0E9814D7E3CBCDBCAF28FF21EE4EADAE6DF52001944A40414DFF280FF043B14838288BE7F9438DC71ABBC2C28BF78F34ADF3D1C912579A19020125

public-key-code end

peer-public-key end

#

local-user ftp

password cipher $c$3$sg9WgqO1w8vnAv2FKGTOYgFJm3nn2w==

authorization-attribute work-directory flash:/

authorization-attribute user-role network-operator

service-type ftp

#

ftp server enable

#

6  设备作为Stelnet客户端配置举例(password认证)

6.1  组网需求

图12所示,Device A作为Stelnet客户端,采用SSH协议远程登录到Device B上。要求:

·     Device B采用本地认证的方式认证用户,Stelnet服务器采用的认证方式为password认证。

·     登录用户名为client001,密码为aabbcc,用户登录设备后可以正常使用所有命令。

·     为提高安全性,需要以Stelnet客户端保存的主机公钥来验证Stelnet服务器,Stelnet客户端只信任通过验证的Stelnet服务器并继续访问该服务器。

图12 设备作为Stelnet客户端配置组网图

 

6.2  配置思路

·     为了使SSH的版本协商和算法协商过程正常运行,且为了保证客户端对连接的服务器的认证正常进行,请在服务器端生成RSA、DSA或ECDSA密钥对。

·     Stelnet客户端通过VTY用户线访问设备。因此,需要配置登录用户线的认证方式为scheme方式。

·     为了采用本地认证的方式认证用户,需要在Stelnet服务器上创建相应的本地用户,并在本地用户视图下配置密码。

·     为了使Stelnet用户登录设备后能正常使用所有命令,将用户的用户角色设置为network-admin,缺省情况下本地用户的用户角色为network-operator。

·     因为需要以Stelnet客户端保存的主机公钥来验证Stelnet服务器,所以需要先将Stelnet服务器主机公钥配置在Stelnet客户端上。

6.3  使用版本

本举例进行配置和验证所使用的版本,如表3所示。

表3 产品与软件版本适配关系

产品

软件版本

S12500X-AF系列交换机

S12500X-CMW710-R2712

S12500-X系列交换机

S12500X-CMW710-R2712

S9800系列交换机

S9800-CMW710-R2712

 

6.4  配置注意事项

缺省情况下,S12500X-AF系列、S12500-X系列、S9800系列交换机的接口处于ADM(Administratively Down)状态,请根据实际需要在对应接口视图下使用undo shutdown命令开启接口。

6.5  配置步骤

6.5.1  Stelnet服务器的配置

# 生成RSA密钥对。

<DeviceB> system-view

[DeviceB] public-key local create rsa

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.

# 生成DSA密钥对。

[DeviceB] public-key local create 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.

# 生成ECDSA密钥对。

[DeviceB] public-key local create ecdsa secp256r1

Generating Keys...

.

Create the key pair successfully.

# 使能SSH服务器功能。

[DeviceB] ssh server enable

# 创建VLAN 2,并将Ten-GigabitEthernet1/0/2加入VLAN 2。

[DeviceB] vlan 2

[DeviceB-vlan2] port ten-gigabitethernet 1/0/2

[DeviceB-vlan2] quit

# 配置VLAN接口2的IP地址,客户端将通过该地址连接Stelnet服务器。

[DeviceB] interface vlan-interface 2

[DeviceB-Vlan-interface2] ip address 192.168.1.40 255.255.255.0

[DeviceB-Vlan-interface2] quit

# 设置Stelnet客户端登录用户界面的认证方式为scheme。

[DeviceB] line vty 0 63

[DeviceB-line-vty0-63] authentication-mode scheme

[DeviceB-line-vty0-63] quit

# 创建本地用户client001,并设置密码为明文aabbcc,服务类型为SSH,用户角色为network-admin。

[DeviceB]local-user client001 class manage

New local user added.

[DeviceB-luser-manage-client001] password simple aabbcc

[DeviceB-luser-manage-client001]service-type ssh

[DeviceB-luser-manage-client001] authorization-attribute user-role network-admin

[DeviceB-luser-manage-client001]quit

# 显示服务器端DSA公钥内容。

[DeviceB] display public-key local dsa public

 

=====================================================

Key name: dsakey (default)

Key type: DSA

Time when key pair created: 11:02:10 2016/07/07

Key code:

 

   308201B73082012C06072A8648CE3804013082011F02818100D757262C4584C44C211F18BD

   96E5F061C4F0A423F7FE6B6B85B34CEF72CE14A0D3A5222FE08CECE65BE6C265854889DC1E

   DBD13EC8B274DA9F75BA26CCB987723602787E922BA84421F22C3C89CB9B06FD60FE01941D

   DD77FE6B12893DA76EEBC1D128D97F0678D7722B5341C8506F358214B16A2FAC4B36895038

   7811C7DA33021500C773218C737EC8EE993B4F2DED30F48EDACE915F0281810082269009E1

   4EC474BAF2932E69D3B1F18517AD9594184CCDFCEAE96EC4D5EF93133E84B47093C52B20CD

   35D02492B3959EC6499625BC4FA5082E22C5B374E16DD00132CE71B020217091AC717B6123

   91C76C1FB2E88317C1BD8171D41ECB83E210C03CC9B32E810561C21621C73D6DAAC028F4B1

   585DA7F42519718CC9B09EEF03818400028180077F06B3E343CAE9988F4BE3F76FACBAB565

   AB73D4BA295C52BA92428B1F2DA1E6DD652413DD3AFE0C5A4FCF365100CBE34CECA55A2C30

   A2A9FF7E899628557E39CE8FC615F53193A7E200B4B1CB21E3F1091D595716D229DDED6872

   061F9B4B08301ADC81F7EC1501FFB863C0009536596CCB508596C3325892DC6D8C5C35B5

6.5.2  Stelnet客户端的配置

# 创建VLAN 2,并将Ten-GigabitEthernet1/0/2加入VLAN 2。

<DeviceA> system-view

[DeviceA] vlan 2

[DeviceA-vlan2] port ten-gigabitethernet 1/0/2

[DeviceA-vlan2] quit

# 配置VLAN接口2的IP地址。

[DeviceA] interface vlan-interface 2

[DeviceA-Vlan-interface2] ip address 192.168.1.56 255.255.255.0

[DeviceA-Vlan-interface2] quit

# 指定服务器端的主机公钥名称为key1,并进入公钥视图。

[DeviceA] public-key peer key1

Enter public key view. Return to system view with "peer-public-key end" command.

# 在客户端配置服务器端的主机公钥(由于客户端缺省采用DSA主机公钥认证服务器,因此这里输入的是在在服务器端通过display public-key local dsa public命令显示公钥内容。)

[DeviceA-pkey-public-key-key1]308201B73082012C06072A8648CE3804013082011F02818100D757262C4584C44C211F18BD96E5F061C4F0A423F7FE6B6B85B34CEF72CE14A0D3A5222FE08CECE65BE6C265854889DC1EDBD13EC8B274DA9F75BA26CCB987723602787E922BA84421F22C3C89CB9B06FD60FE01941DDD77FE6B12893DA76EEBC1D128D97F0678D7722B5341C8506F358214B16A2FAC4B368950387811C7DA33021500C773218C737EC8EE993B4F2DED30F48EDACE915F0281810082269009E14EC474BAF2932E69D3B1F18517AD9594184CCDFCEAE96EC4D5EF93133E84B47093C52B20CD35D02492B3959EC6499625BC4FA5082E22C5B374E16DD00132CE71B020217091AC717B612391C76C1FB2E88317C1BD8171D41ECB83E210C03CC9B32E810561C21621C73D6DAAC028F4B1585DA7F42519718CC9B09EEF03818400028180077F06B3E343CAE9988F4BE3F76FACBAB565AB73D4BA295C52BA92428B1F2DA1E6DD652413DD3AFE0C5A4FCF365100CBE34CECA55A2C30A2A9FF7E899628557E39CE8FC615F53193A7E200B4B1CB21E3F1091D595716D229DDED6872061F9B4B08301ADC81F7EC1501FFB863C0009536596CCB508596C3325892DC6D8C5C35B5

# 退出公钥视图,并保存用户输入的公钥。

[DeviceA-pkey-public-key-key1] peer-public-key end

[DeviceA] return

6.6  验证配置

# 建立到服务器192.168.1.40的SSH连接,并指定服务器端的主机公钥key1。输入正确的用户名和密码之后,即可成功登录到Device B上,用户角色为network-admin。

<DeviceA> ssh2 192.168.1.40 publickey key1

login as: client001

client001@192.168.1.40's password:

 

******************************************************************************

* Copyright (c) 2004-2018 New H3C Technologies Co., Ltd. All rights reserved.*

* Without the owner's prior written consent,                                 *

* no decompiling or reverse-engineering shall be allowed.                    *

******************************************************************************

 

<DeviceB>

6.7  配置文件

·     DeviceA

#

vlan 2

#

interface Vlan-interface2

ip address 192.168.1.56 255.255.255.0

#

interface Ten-GigabitEthernet1/0/2

 port link-mode bridge

 port access vlan 2

#

public-key peer key1

public-key-code begin

308201B73082012C06072A8648CE3804013082011F02818100D757262C4584C44C211F18BD

   96E5F061C4F0A423F7FE6B6B85B34CEF72CE14A0D3A5222FE08CECE65BE6C265854889DC1E

   DBD13EC8B274DA9F75BA26CCB987723602787E922BA84421F22C3C89CB9B06FD60FE01941D

   DD77FE6B12893DA76EEBC1D128D97F0678D7722B5341C8506F358214B16A2FAC4B36895038

   7811C7DA33021500C773218C737EC8EE993B4F2DED30F48EDACE915F0281810082269009E1

   4EC474BAF2932E69D3B1F18517AD9594184CCDFCEAE96EC4D5EF93133E84B47093C52B20CD

   35D02492B3959EC6499625BC4FA5082E22C5B374E16DD00132CE71B020217091AC717B6123

   91C76C1FB2E88317C1BD8171D41ECB83E210C03CC9B32E810561C21621C73D6DAAC028F4B1

   585DA7F42519718CC9B09EEF03818400028180077F06B3E343CAE9988F4BE3F76FACBAB565

   AB73D4BA295C52BA92428B1F2DA1E6DD652413DD3AFE0C5A4FCF365100CBE34CECA55A2C30

   A2A9FF7E899628557E39CE8FC615F53193A7E200B4B1CB21E3F1091D595716D229DDED6872

   061F9B4B08301ADC81F7EC1501FFB863C0009536596CCB508596C3325892DC6D8C5C35B5

public-key-code end

peer-public-key end

#

·     DeviceB

#

vlan 2

#

interface Vlan-interface2

 ip address 192.168.1.40 255.255.255.0

#

interface Ten-GigabitEthernet1/0/2

 port link-mode bridge

 port access vlan 2

#

line vty 0 63

 authentication-mode scheme

#

ssh server enable

#

local-user client001

 password cipher $c$3$o71Exx1XIKs9gJoxqSodHGl1uT9rlZEd4w==

authorization-attribute user-role network-operator

 authorization-attribute user-role network-admin

 service-type ssh

#

7  设备作为SFTP客户端配置举例(password-publickey认证)

7.1  组网需求

图13所示,Device A和Device B之间建立SSH连接,Device A作为SFTP客户端登录到Device B,进行文件管理和文件传送等操作。要求:

·     为了保证高安全性和认证强度,要求Device B通过password-publickey认证方式对客户端进行认证,公钥算法为RSA。

·     登录用户名为client001,密码为aabbcc,用户登录设备后可以正常使用所有命令。

·     服务器端通过从公钥文件中导入的方式来配置客户端的公钥。

图13 设备作为SFTP客户端配置组网图

 

7.2  配置思路

·     为了采用本地认证认证用户,需在本地SFTP服务器DeviceB上创建相应的本地用户,并在本地用户视图下配置密码。

·     服务器在采用publickey方式验证客户端身份时,首先要比较客户端发送的SSH用户名、主机公钥是否与本地配置的SSH用户名以及相应的客户端主机公钥一致,在确认用户名和客户端主机公钥正确后,再对客户端发送的数字签名进行验证,而该签名是客户端利用主机公钥对应的私钥计算出的。因此,需要在服务器端配置客户端的RSA主机公钥,并在客户端为该SSH用户指定与主机公钥对应的RSA主机私钥(在向服务器发起连接时通过identity-key关键字指定公钥算法来实现)。

·     如果SSH服务器采用publickey方式认证客户端,必须在SFTP服务器上创建相应的SSH用户,以及同名的本地用户(用于下发授权属性:工作目录、用户角色)。

·     在服务器的配置过程中需要指定客户端的公钥信息,因此需要首先完成客户端密钥对的配置,再进行服务器的配置。

·     因为SFTP用户登录设备后要能正常使用所有命令,所以将用户的用户角色设置为network-admin,缺省情况下本地用户的用户角色为network-operator。

7.3  使用版本

本举例进行配置和验证所使用的版本,如表4所示。

表4 产品与软件版本适配关系

产品

软件版本

S12500X-AF系列交换机

S12500X-CMW710-R2712

S12500-X系列交换机

S12500X-CMW710-R2712

S9800系列交换机

S9800-CMW710-R2712

 

7.4  配置注意事项

·     FIPS模式下,设备作为SSH服务器不支持publickey认证方式。

·     虽然一个客户端只会采用RSA、DSA或ECDSA公钥算法中的一种来认证服务器,但是由于不同客户端支持的公钥算法不同,为了确保客户端能够成功登录服务器,建议在服务器上同时生成RSA、DSA和ECDSA密钥对。

·     缺省情况下,S12500X-AF系列、S12500-X系列、S9800系列交换机的接口处于ADM(Administratively Down)状态,请根据实际需要在对应接口视图下使用undo shutdown命令开启接口。

7.5  配置步骤

7.5.1  SFTP客户端的配置

# 创建VLAN 2,并将Ten-GigabitEthernet1/0/2加入VLAN 2。

<DeviceA> system-view

[DeviceA] vlan 2

[DeviceA-vlan2] port ten-gigabitethernet 1/0/2

[DeviceA-vlan2] quit

# 配置VLAN接口2的IP地址。

[DeviceA] interface vlan-interface 2

[DeviceA-Vlan-interface2] ip address 192.168.0.2 255.255.255.0

[DeviceA-Vlan-interface2] quit

# 生成RSA密钥对。

[DeviceA] public-key local create rsa

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.

# 将生成的RSA主机公钥导出到指定文件key.pub中。

[DeviceA] public-key local export rsa ssh2 key.pub

[DeviceA] quit

7.5.2  配置DeviceB作为FTP服务器

# 创建VLAN 2,并将Ten-GigabitEthernet1/0/2加入VLAN 2。

<DeviceB> system-view

[DeviceB] vlan 2

[DeviceB-vlan2] port ten-gigabitethernet 1/0/2

[DeviceB-vlan2] quit

# 配置VLAN接口2的IP地址。

[DeviceB] interface vlan-interface 2

[DeviceB-Vlan-interface2] ip address 192.168.0.1 255.255.255.0

[DeviceB-Vlan-interface2] quit

# 在Device上创建一个ftp类型的本地用户,并设置密码为明文ftp,服务类型为FTP,用户角色为network-admin,工作目录为flash:/。

[DeviceB] local-user ftp class manage

New local user added.

[DeviceB-luser-manage-ftp] password simple ftp

[DeviceB-luser-manage-ftp] authorization-attribute user-role network-admin

[DeviceB-luser-manage-ftp] authorization-attribute work-directory flash:/

[DeviceB-luser-manage-ftp] service-type ftp

[DeviceB-luser-manage-ftp] quit

# 开启Device 的FTP服务器功能。

[DeviceB] ftp server enable

[DeviceB] quit

7.5.3  配置客户端DeviceA上传公钥文件

# DeviceA通过FTP登录并上传flash:/路径下的公钥文件key.pub到Device。

<DeviceA>ftp 192.168.0.1

Press CTRL+C to abort.

Connected to 192.168.0.1 (192.168.0.1).

220 FTP service ready.

User (192.168.0.2:(none)): ftp

331 Password required for ftp.

Password:

230 User logged in.

Remote system type is UNIX.

Using binary mode to transfer files.

ftp> put flash:/key.pub

227 Entering Passive Mode (192,168,0,1,41,116)

150 Accepted data connection

226 File successfully transferred

301 bytes sent in 0.000 seconds (1.05 Mbytes/s)

ftp> quit

221-Goodbye. You uploaded 1 and downloaded 0 kbytes.

221 Logout.

7.5.4  配置Device B作为SFTP服务器

# 生成RSA密钥对。

<DeviceB> system-view

[DeviceB] public-key local create rsa

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.

# 生成DSA密钥对。

[DeviceB] public-key local create 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.

# 生成ECDSA密钥对。

[DeviceB] public-key local create ecdsa secp256r1

Generating Keys...

.

Create the key pair successfully.

# 启动SFTP服务器。

[DeviceB] sftp server enable

# 从文件key.pub中导入远端的公钥,并命名为devicekey。

[DeviceB] public-key peer devicekey import sshkey key.pub

# 设置SSH用户client001的服务类型为SFTP,认证方式为password-publickey,并指定公钥为devicekey。

[DeviceB] ssh user client001 service-type sftp authentication-type password-publickey assign publickey devicekey

# 创建设备管理类本地用户client001,并设置密码为明文aabbcc,服务类型为SSH,用户角色为network-admin,工作目录为flash:/。

[DeviceB] local-user client001 class manage

New local user added.

[DeviceB-luser-manage-client001] password simple aabbcc

[DeviceB-luser-manage-client001] service-type ssh

[DeviceB-luser-manage-client001] authorization-attribute user-role network-admin work-directory flash:/

[DeviceB-luser-manage-client001] quit

7.6  验证配置

# 与远程SFTP服务器建立连接。

<DeviceA >sftp 192.168.0.1 identity-key rsa

Username: client001

Press CTRL+C to abort.

Connecting to 192.168.0.1 port 22.

The server is not authenticated. Continue? [Y/N]:y

Do you want to save the server public key? [Y/N]:n

client001@192.168.0.1's password:

# 输入用户密码aabbcc后进入SFTP客户端视图。

sftp>

# 显示服务器的当前目录,删除文件z,并检查此文件是否删除成功。

sftp> dir -l

-rwxrwxrwx    1 1        1              1759 Aug 23 06:52 config.cfg

-rw-rw----    1 1        1               301 Aug  7 16:52 key.pub

-rwxrwxrwx    1 1        1                0 Sep 01 06:22 new

-rwxrwxrwx    1 1        1              225 Sep 01 06:55 pub

-rwxrwxrwx    1 1        1              225 Aug 24 08:01 pubkey2

-rwxrwxrwx    1 1        1                0 Sep 01 08:00 z

sftp> delete z

Removing /z

sftp> dir -l

-rwxrwxrwx    1 1        1              1759 Aug 23 06:52 config.cfg

-rw-rw----    1 1        1               301 Aug  7 16:52 key.pub

-rwxrwxrwx    1 1        1                0 Sep 01 06:22 new

-rwxrwxrwx    1 1        1              225 Sep 01 06:55 pub

-rwxrwxrwx    1 1        1              225 Aug 24 08:01 pubkey2

# 新增目录new1,并检查新目录是否创建成功。

sftp> mkdir new1

sftp> dir -l

-rwxrwxrwx    1 1        1              1759 Aug 23 06:52 config.cfg

-rw-rw----    1 1        1               301 Aug  7 16:52 key.pub

-rwxrwxrwx    1 1        1                0 Sep 01 06:22 new

drwxrwxrwx    1 1        1                0 Sep 02 06:30 new1

-rwxrwxrwx    1 1        1              225 Sep 01 06:55 pub

-rwxrwxrwx    1 1        1              225 Aug 24 08:01 pubkey2

# 将目录名new1更名为new2,并查看是否更名成功。

sftp> rename new1 new2

sftp> dir -l

-rwxrwxrwx    1 1        1              1759 Aug 23 06:52 config.cfg

-rw-rw----    1 1        1               301 Aug  7 16:52 key.pub

-rwxrwxrwx    1 1        1                0 Sep 01 06:22 new

drwxrwxrwx    1 1        1                0 Sep 02 06:33 new2

-rwxrwxrwx    1 1        1              225 Sep 01 06:55 pub

-rwxrwxrwx    1 1        1              225 Aug 24 08:01 pubkey2

# 从服务器上下载文件pubkey2到本地,并更名为public。

sftp> get pubkey2 public

Fetching /pubkey2 to public

/public                                       100%  301     0.3KB/s   00:00

# 将本地文件public上传到服务器上,并查看上传是否成功。

sftp> put public

Uploading public to /public

public                                        100%  301     0.3KB/s   00:00

sftp> dir -l

-rwxrwxrwx    1 1        1              1759 Aug 23 06:52 config.cfg

-rw-rw----    1 1        1               301 Aug  7 16:52 key.pub

-rwxrwxrwx    1 1        1                0 Sep 01 06:22 new

drwxrwxrwx    1 1        1                0 Sep 02 06:33 new2

-rwxrwxrwx    1 1        1              225 Sep 01 06:55 pub

-rwxrwxrwx    1 1        1              225 Aug 24 08:01 pubkey2

-rwxrwxrwx    1 1        1              301 Jul 30 16:21 public

sftp>

# 退出SFTP客户端视图。

sftp> quit

<DeviceA>

7.7  配置文件

·     DeviceA

#

vlan 2

#

interface Vlan-interface2

ip address 192.168.0.2 255.255.255.0

#

interface Ten-GigabitEthernet1/0/2

 port link-mode bridge

 port access vlan 2

#

·     DeviceB

#

vlan 2

#

interface Vlan-interface2

 ip address 192.168.0.1 255.255.255.0

#

interface Ten-GigabitEthernet1/0/2

 port link-mode bridge

 port access vlan 2

#

sftp server enable

ssh user client001 service-type sftp authentication-type password-publickey assign publickey devicekey

#

local-user client001 class manage

service-type ssh

password cipher $c$3$o71Exx1XIKs9gJoxqSodHGl1uT9rlZEd4w==

 authorization-attribute user-role network-operator

 authorization-attribute user-role network-admin

#

ftp server enable

#

local-user ftp class manage

 password simple ftp

 service-type ftp

 authorization-attribute user-role network-admin

 authorization-attribute user-role network-operator

#

public-key peer devicekey

 public-key-code begin

30819F300D06092A864886F70D010101050003818D00308189

1BD316C0DBB9009503E78F31947B651F9950E9A6E9E256E1E

 public-key-code end

 peer-public-key end

#

8  SCP文件传输配置举例(password认证)

8.1  组网需求

图14所示,Device A作为SCP客户端,Device B作为SCP服务器。要求:

·     采用password认证方式对SCP客户端进行远程认证,用户能够通过Device A安全地登录到Device B上。

·     采用RADIUS服务器对登录Device B的SCP用户Device A进行认证和授权,登录用户名为hello@bbb,密码为aabbcc,Device A登录Device B后可以正常使用所有命令;

·     Device B向RADIUS服务器发送的用户名带域名。

图14 SCP文件传输配置组网图

 

8.2  配置思路

·     为了使SSH的版本协商和算法协商过程正常运行,且为了保证客户端对连接的服务器的认证正常进行,请在服务器端生成RSA、DSA或ECDSA密钥对。

·     采用RADIUS服务器对登录Device B的SCP用户Device A进行认证,需要在RADIUS服务器上添加用户名和密码。

·     为保证RADIUS客户端和RADIUS服务器之间信息交互的安全性,且为了防止用户密码在不安全的网络上传递时被窃取,需要在Device B和RADIUS服务器上设置相同的共享密钥。

·     为了使Device A登录Device B后可以正常使用所有命令,在RADIUS服务器上设置用户角色为network-admin。

·     为了实现通过RADIUS来进行认证和授权,需要在Device B上配置RADIUS方案指定相应的认证和授权服务器,并配置认证SSH用户的ISP域。

8.3  使用版本

本举例进行配置和验证所使用的版本,如表5所示。

表5 产品与软件版本适配关系

产品

软件版本

S12500X-AF系列交换机

S12500X-CMW710-R2712

S12500-X系列交换机

S12500X-CMW710-R2712

S9800系列交换机

S9800-CMW710-R2712

 

8.4  配置注意事项

缺省情况下,S12500X-AF系列、S12500-X系列、S9800系列交换机的接口处于ADM(Administratively Down)状态,请根据实际需要在对应接口视图下使用undo shutdown命令开启接口。

8.5  配置步骤

8.5.1  配置RADIUS服务器

说明

本文以iMC例(使用iMC版本为:iMC PLAT 7.0(E0102)iMC EIA 7.0(E0201)),说明该例中RADIUS服务器的基本配置。

 

1. 增加接入设备

# 登录进入iMC管理平台,选择“用户”页签,单击导航树中的[接入策略管理/接入设备管理/接入设备配置]菜单项,进入接入设备配置页面,在该页面中单击“增加”按钮,进入增加接入设备页面。

·     设置认证及计费的端口号分别为“1812”(RADIUS服务器的认证端口为UDP端口1812)和“1813”(RADIUS服务器的计费端口为UDP端口1813);

·     选择业务类型为“设备管理业务”;

·     选择接入设备类型为“H3C(General)”;

·     设置与Device交互报文时使用的认证和授权共享密钥为“expert”;

·     选择或手工增加接入设备,添加IP地址为10.1.1.2的接入设备;

·     其它参数采用缺省值,并单击<确定>按钮完成操作。

图15 增加接入设备

2014-03-26_140058.png

 

2. 增加设备管理用户

# 选择“用户”页签,单击导航树中的[接入用户管理视图/设备管理用户]菜单项,进入设备管理用户列表页面,在该页面中单击<增加>按钮,进入增加设备管理用户页面。

·     输入用户名“hello@bbb”和密码“aabbcc”。

·     选择服务类型为“SSH”。

·     输入用户角色名“network-admin”

·     添加所管理设备的IP地址,IP地址范围为“10.1.1.0~10.1.1.255”。

·     单击<确定>按钮完成操作。

图16 增加设备管理用户

 图1.jpg

 

8.5.2  配置Device B

# 生成RSA密钥对。

<DeviceB> system-view

[DeviceB] public-key local create rsa

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.

# 生成DSA密钥对。

[DeviceB] public-key local create 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.

# 生成ECDSA密钥对。

[DeviceB] public-key local create ecdsa secp256r1

Generating Keys...

.

Create the key pair successfully.

# 创建VLAN 2,并将Ten-GigabitEthernet1/0/2加入VLAN 2。

[DeviceB] vlan 2

[DeviceB-vlan2] port ten-gigabitethernet 1/0/2

[DeviceB-vlan2] quit

# 配置接口VLAN接口2的IP地址,SCP客户端将通过该地址连接SCP服务器。

[DeviceB] interface vlan-interface 2

[DeviceB-Vlan-interface2] ip address 192.168.0.1 255.255.255.0

[DeviceB-Vlan-interface2] quit

# 创建VLAN 3,并将Ten-GigabitEthernet1/0/3加入VLAN 3。

[DeviceB] vlan 3

[DeviceB-vlan3] port ten-gigabitethernet 1/0/3

[DeviceB-vlan3] quit

# 配置VLAN接口3的IP地址,RADIUS客户端通过该地址连接RADIUS服务器。

[DeviceB] interface vlan-interface 3

[DeviceB-Vlan-interface3] ip address 10.1.1.2 255.255.255.0

[DeviceB-Vlan-interface3] quit

# 使能SCP服务器功能。

[DeviceB] scp server enable

# 创建RADIUS方案rad。

[DeviceB] radius scheme rad

# 配置主认证服务器的IP地址为10.1.1.1,认证端口号为1812。

[DeviceB-radius-rad] primary authentication 10.1.1.1 1812

# 配置主计费服务器的IP地址为10.1.1.1,计费端口号为1813。

[DeviceB-radius-rad] primary accounting 10.1.1.1 1813

 # 配置与认证和计费服务器交互报文时的共享密钥为明文expert。

[DeviceB-radius-rad] key authentication simple expert

[DeviceB-radius-rad] key accounting simple expert

# 配置向RADIUS服务器发送的用户名要携带域名。

[DeviceB-radius-rad] user-name-format with-domain

[DeviceB-radius-rad] quit

# 创建ISP域bbb,为login用户配置AAA认证方法为RADIUS认证、授权和计费。

[DeviceB] domain bbb

[DeviceB-isp-bbb] authentication login radius-scheme rad

[DeviceB-isp-bbb] authorization login radius-scheme rad

[DeviceB-isp-bbb] accounting login radius-scheme rad

[DeviceB-isp-bbb] quit

8.5.3  配置Device A

# 创建VLAN 2,并将Ten-GigabitEthernet1/0/2加入VLAN 2。

<DeviceA> system-view

[DeviceA] vlan 2

[DeviceA-vlan2] port ten-gigabitethernet 1/0/2

[DeviceA-vlan2] quit

# 配置接口VLAN 2的IP地址。

[DeviceA] interface vlan-interface 2

[DeviceA-Vlan-interface2] ip address 192.168.0.2 255.255.255.0

[DeviceA-Vlan-interface2] quit

[DeviceA] quit

8.6  验证配置

# 与远程SCP服务器建立连接,并下载远端的remote.bin文件,下载到本地后更名为local.bin。

<DeviceA> scp 192.168.0.1 get remote.bin local.bin

Username: hello@bbb

Press CTRL+C to abort.

Connecting to 192.168.0.1 port 22.

The Server is not authenticated. Continue? [Y/N]:y

Do you want to save the server public key? [Y/N]:n

hello@bbb@192.168.0.1's password:

remote.bin                    100% 8275KB 318.3KB/s   00:26.

8.7  配置文件

·     DeviceA

#

vlan 2

#

interface Vlan-interface2

ip address 192.168.0.2 255.255.255.0

#

interface Ten-GigabitEthernet1/0/2

 port link-mode bridge

 port access vlan 2

#

·     DeviceB

#

vlan 2 to 3

#

interface Vlan-interface2

 ip address 192.168.0.1 255.255.255.0

#

interface Vlan-interface3

 ip address 10.1.1.2 255.255.255.0

#

interface Ten-GigabitEthernet1/0/2

 port link-mode bridge

 port access vlan 2

#

interface Ten-GigabitEthernet1/0/3

 port link-mode bridge

 port access vlan 3

#

ssh server enable

#

radius scheme rad

 primary authentication 10.1.1.1

 primary accounting 10.1.1.1

 key authentication cipher $c$3$63G7LzIQElGq4aFGTiYQafU+loQxS/cbLg==

 key accounting cipher $c$3$tUIVlyGISJ5X/yiTFWrmh8nyjBIF+1LFzQ==

#

domain bbb

 authentication login radius-scheme rad

 authorization login radius-scheme rad

 accounting login radius-scheme rad

#

9  相关资料

·     H3C S12500X-AF & S12500-X & S9800系列交换机 基础配置指导(R27xx)

·     H3C S12500X-AF & S12500-X & S9800系列交换机 基础配置命令参考(R27xx)

不同款型规格的资料略有差异, 详细信息请向具体销售和400咨询。H3C保留在没有任何通知或提示的情况下对资料内容进行修改的权利!

新华三官网
联系我们