首先说明:Linux上的ssh ip-address 在华为设备上 的命令是stelnet ip-address
由于通过STelnet登录设备需配置用户界面支持的协议是SSH
- 对于USG系列,将接口加入安全区域,并配置域间包过滤,以保证网络基本通信正常,具体步骤略。对于USG BSR/HSR系列,不需要将接口加入安全区域以及配置包过滤。
- 在服务器端生成本地密钥对。
<USG> system-view [USG] rsa local-key-pair create The key name will be: USG_Host The range of public key size is (512 ~ 2048). NOTES: If the key modulus is greater than 512, It will take a few minutes. Input the bits in the modulus[default = 512]: Generating keys... .......++++++++++++ ..........++++++++++++ ...................................++++++++ ......++++++++
- 在服务器端创建SSH用户。 说明:
SSH用户主要有password、RSA、password-rsa、all这4种认证方式:
-
如果SSH用户的认证方式为password、password-rsa时,必须配置同名的local-user用户。
-
如果SSH用户的认证方式为RSA、password-rsa、all,服务器端应保存SSH客户端的RSA公钥。
# 配置VTY用户界面。
[USG] user-interface vty 0 4 [USG-ui-vty0-4] authentication-mode aaa [USG-ui-vty0-4] protocol inbound ssh [USG-ui-vty0-4] quit
-
创建SSH用户Client001。
# 新建用户名为Client001的SSH用户,且认证方式为password。
[USG] ssh user client001 [USG] ssh user client001 authentication-type password
# 为SSH用户Client001配置密码为Admin@123。
[USG] aaa [USG-aaa] local-user client001 password simple Admin@123 [USG-aaa] local-user client001 service-type ssh
-
新建用户名为Client002的SSH用户,且认证方式为RSA。
[USG] ssh user client002 [USG] ssh user client002 authentication-type rsa
-
- 客户端生成客户端的本地密钥对。
<USG> system-view [USG] sysname client002 [client002] rsa local-key-pair create
使用该命令进行配置时,如果RSA密钥已经存在,则进行告警,并提示原有密钥被更换。产生的密钥对命名为“hostkey”和“serverkey”。
配置完成后,通过display rsa local-key-pair public查看客户端上生成RSA公钥。
- 配置服务器端RSA公钥。
# 将客户端上产生的“hostkey”密钥复制到服务器端。
[USG] rsa peer-public-key RsaKey001 Enter "RSA public key" view, return system view with "peer-public-key end". [USG-rsa-public-key] public-key-code begin Enter "RSA key code" view, return last view with "public-key-code end". [USG-rsa-key-code] 3047 [USG-rsa-key-code] 0240 [USG-rsa-key-code] BFF35E4B C61BD786 F907B5DE 7D6770C3 E5FD17AB [USG-rsa-key-code] 203C8FCB BBC8FDF2 F7CB674E 519E8419 0F6B97A8 [USG-rsa-key-code] EA91FC4B B9E18836 5E74BFD5 4C687767 A89C6B43 [USG-rsa-key-code] 1D7E3E1B [USG-rsa-key-code] 0203 [USG-rsa-key-code] 010001 [USG-rsa-key-code] public-key-code end [USG-rsa-public-key] peer-public-key end
- 为SSH用户Client002绑定SSH客户端的RSA公钥。
[USG] ssh user client002 assign rsa-key RsaKey001 //必须配置
- SSH服务器端STelnet服务使能。
# 使能STelnet服务功能。
[USG] stelnet server enable
- 配置SSH用户Client001、Client002的服务方式为STelnet。
[USG] ssh user client001 service-type stelnet [USG] ssh user client002 service-type stelnet
- STelnet客户端连接SSH服务器。
# 第一次登录,需要使能SSH客户端首次认证功能。
<USG> system-view [USG] sysname client001 [client001] ssh client first-time enable
<client002> system-view [client002] ssh client first-time enable
# STelnet客户端Client001用password认证方式连接SSH服务器,输入配置的用户名和密码。
<client001> system-view [client001] stelnet 10.164.39.222 Please input the username:client001 Trying 10.164.39.222 ... Press CTRL+K to abort Connected to 10.164.39.222 ... The server is not authenticated. Do you continue to access it?(Y/N):y Do you want to save the server's public key?(Y/N):y The server's public key will be saved with the name: 10.164.39.222. Please wait... Enter password:
输入密码Admin@123,显示登录成功信息如下:
<USG>
# STelnet客户端Clent002用RSA认证方式连接SSH服务器。
<client002> system-view [client002] stelnet 10.164.39.223 Please input the username: client002 Trying 10.164.39.223 ... Press CTRL+K to abort Connected to 10.164.39.223... The server is not authenticated. Do you continue to access it?(Y/N):y Do you want to save the server's public key?(Y/N):y The server's public key will be saved with the name: 10.164.39.223. Please wait... Note: The max number of VTY users is 10, and the current number of VTY users on line is 5. <USG>