

在网络配置中,确保安全的数据交互是至关重要的。为了实现这一目标,带大家看看如何通过配置SSH服务器端和客户端,使用STelnet服务功能来实现安全登录和数据交互。
组网需求
如图1所示,用户希望在服务器端和客户端进行安全的数据交互,配置一个登录用户为client001,使用password认证方式登录SSH服务器。
图1 配置通过STelnet登录其他设备组网图
配置思路
1.在SSH服务器端配置SSH用户client001的认证方式为Password认证。
2.在SSH服务器端开启STelnet服务功能。
3.在SSH服务器端配置SSH用户client001的服务方式为STelnet。
4.用户client001以STelnet方式实现登录SSH服务器。
Password认证不安全,实际应用中建议使用AAA认证。
操作步骤
1.在服务器端创建SSH用户。
# 配置VTY用户界面。
[HUAWEI] sysname SSH Server
[SSH Server] user-interface vty 0 4
[SSH Server-ui-vty0-4] authentication-mode aaa
[SSH Server-ui-vty0-4] protocol inbound ssh
[SSH Server-ui-vty0-4] user privilege level 15
[SSH Server-ui-vty0-4] quit
创建SSH用户client001。
# 新建用户名为client001的SSH用户,认证方式为password,密码是YsHsjx_202206。
[SSH Server] ssh user client001
[SSH Server] ssh user client001 authentication-type password
[SSH Server] aaa
[SSH Server-aaa] local-user client001 password irreversible-cipher YsHsjx_202206
[SSH Server-aaa] local-user client001 privilege level 15
[SSH Server-aaa] local-user client001 service-type ssh
[SSH Server-aaa] quit
2.SSH服务器端开启STelnet服务功能。[SSH Server] stelnet server enable
[SSH Server] ssh server-source -i Vlanif 10 //仅V200R020C00及之后版本需要配置这条命令。此处假设客户端使用IP地址10.1.1.1连接服务器,该地址对应的接口为Vlanif 10
3.配置SSH用户client001的服务方式为STelnet。[SSH Server] ssh user client001 service-type stelnet
4.STelnet客户端连接SSH服务器。
# 第一次登录,需要使能SSH客户端首次认证功能。使能客户端Client001首次认证功能。
[HUAWEI] sysname client001
[client001] ssh client first-time enable
# STelnet客户端Client001用password认证方式连接SSH服务器,输入配置的用户名和密码。
[client001] stelnet 10.1.1.1
Please input the username:client001
Trying 10.1.1.1 ...
Press CTRL+K to abort
Connected to 10.1.1.1 ...
The server is not authenticated. Continue to access it? [Y/N] :y
Save the server's public key? [Y/N] :y
The server's public key will be saved with the name 10.1.1.1. Please wait...
Please select public key type for user authentication [R for RSA; D for DSA; Enter for Skip publickey authentication; Ctrl_C for Can
cel], Please select [R, D, Enter or Ctrl_C]:d
Enter password:
输入密码,显示登录成功信息如下:
5.验证配置结果。
在SSH服务器端执行display ssh server status命令可以查看到STelnet服务已经使能。执行display ssh user-information命令可以查看服务器端SSH用户信息。
# 查看SSH状态信息。
[SSH Server] display ssh server status
SSH version :2.0
SSH connection timeout :60 seconds
SSH server key generating interval :0 hours
SSH authentication retries :3 times
SFTP server :Disable
Stelnet server :Enable
Scp server :Disable
SSH server source :0.0.0.0
ACL4 number :0
ACL6 number :0
# 查看SSH用户信息。
[SSH Server] display ssh user-information
User 1:
User Name : client001
Authentication-type : password
User-public-key-name : -
User-public-key-type : -
Sftp-directory : -
Service-type : stelnet
Authorization-cmd : No
通过以上配置和操作步骤,我们成功地实现了SSH服务器端和客户端之间的安全数据交互,同时保证了用户client001的安全认证和登录。在实际应用中,建议使用更加安全的AAA认证方式,以进一步提升网络安全性。