素材来源:华为路由器配置指南
一边学习一边整理试验笔记,并与大家分享,侵权即删,谢谢支持!
附上汇总贴:玩转华为ENSP模拟器系列 | 合集_COCOgsta的博客-CSDN博客_华为模拟器实验
目标
通过STelnet登录其他设备配置的示例。在本示例中,通过在STelnet客户端和SSH服务器端生成本地密钥对,在SSH服务器端生成ECC公钥、并为用户绑定该ECC公钥,实现Stelnet客户端连接SSH服务器。
组网需求
网络中有大量设备需要管理与维护,用户不可能为每台设备连接用户终端,特别是终端与需要管理的设备之间无可达路由时,用户可以使用Telnet方式从当前设备登录到网络上另一台设备,从而实现对远程设备的管理与维护。但是Telnet缺少安全的认证方式,而且传输过程采用TCP进行明文传输,存在很大的安全隐患。
而STelnet是一种安全的Telnet服务,建立在SSH连接的基础之上。SSH可以利用加密和强大的认证功能提供安全保障,保护设备不受诸如IP地址欺诈、简单密码截取等攻击。SSH服务器端STelnet服务使能后,STelnet客户端可以通过Password、RSA、password-rsa、ECC、password-ecc或all认证的方式登录到SSH服务器端。如图1所示,配置两个登录用户为client001和client002,分别使用password方式和ECC方式登录SSH服务器。
配置思路
- 在SSH服务器上配置用户client001和client002,分别使用不同的认证方式登录SSH服务器。
- 分别在STelnet客户端Client002和SSH服务器端生成本地密钥对,并为用户client002绑定SSH客户端的ECC公钥,实现客户端登录服务器端时,对客户端进行验证。
- SSH服务器端STelnet服务使能。
- 配置SSH用户client001和client002的服务方式为STelnet。
- 使能SSH客户端首次认证功能。
- 用户client001和client002分别以STelnet方式实现登录SSH服务器。
操作步骤
- 在服务器端生成本地密钥对
SSH Server: sysname SSH Server ecc local-key-pair create
- 在服务器端创建SSH用户
配置VTY用户界面。
SSH Server: user-interface vty 0 4 authentication-mode aaa user privilege level 3 protocol inbound ssh
创建SSH用户Client001。
新建用户名为Client001的SSH用户,且认证方式为password。
SSH Server: ssh user client001 ssh user client001 authentication-type password
为SSH用户Client001配置密码为Hello-huawei123。
SSH Server:
aaa
local-user client001 password irreversible-cipher $1c$y$Ro$5uraS$lT&,/_{W#VXex&PUR^9gH5~'B4>5KJ99K-9/}xX$
local-user client001 service-type ssh
创建SSH用户Client002。
新建用户名为Client002的SSH用户,且认证方式为ECC。
SSH Server: ssh user client002 ssh user client002 authentication-type ecc ssh authorization-type default root
- 配置服务器端ECC公钥
客户端Client002生成客户端的本地密钥对
SSH Server: sysname client002 ecc local-key-pair create
查看客户端上生成ECC公钥。
[~client002]display ecc local-key-pair public ======================================================== Time of Key pair created : 2019-10-21 18:05:23 Key Name : client002_Host_ECC Key modulus : 521 Key Type : ECC Encryption Key ======================================================== Key Code: 040015A7 6C57151F 0391830B 6462795B 4F5D6524 6CA99B24 3C901FB4 6BB5428D 95045942 9793B5BC 78739E65 139E893F B8CDD837 7CDD6588 B6DC88AB 2859DD44 BC18B100 7552F559 170B1423 194F2285 8F916E5B 63CC2125 99148135 B3C38A77 650862D6 BB29ACFC ECAF54B5 259734DB 2E77F356 3FFBA545 DF131419 1FE7A0BB F33BB77E 22 Host public key for PEM format code: ---- BEGIN SSH2 PUBLIC KEY ---- AAAAE2VjZHNhLXNoYTItbmlzdHA1MjEAAAAIbmlzdHA1MjEAAACFBAAVp2xXFR8D kYMLZGJ5W09dZSRsqZskPJAftGu1Qo2VBFlCl5O1vHhznmUTnok/uM3YN3zdZYi2 3IirKFndRLwYsQB1UvVZFwsUIxlPIoWPkW5bY8whJZkUgTWzw4p3ZQhi1rsprPzs r1S1JZc02y5381Y/+6VF3xMUGR/noLvzO7d+Ig== ---- END SSH2 PUBLIC KEY ---- [~client002]
将客户端上产生的ECC公钥传送到服务器端。
SSH Server: ecc peer-public-key 1.1.1.1 public-key-code begin 0400CB04 85C462A2 2169E6B4 CD089C0D 4E27A587 C7D8AAE3 A3FD2714 A7414857 747BC1F8 E4797A8E CBA0FCE6 475260FE BB5F3C5B 219594DF D7A59B3C 1C5CEEA2 6ADD5400 B10DF3F1 DDC7A255 38A27469 2BD67DBD AE0A0B40 C3B9C7DC 6D7C83DD 5FBB3E84 CC057512 1B6D652B 1E722161 3915932B 003C2B7E CC591551 4A4F31E1 5D5E140E F9 public-key-code end peer-public-key end
- 为SSH用户Client002绑定SSH客户端的ECC公钥。
SSH Server: ssh user client002 assign ecc-key ecckey001
- SSH服务器端STelnet服务使能
使能STelnet服务功能。
SSH Server: stelnet server enable
配置SSH用户Client001、Client002的服务方式为STelnet
SSH Server: ssh user client001 service-type stelnet ssh user client002 service-type stelnet
- STelnet客户端连接SSH服务器
第一次登录,需要使能SSH客户端首次认证功能。
使能客户端Client001首次认证功能。
client001: sysname client001 ssh client first-time enable
使能客户端Client002首次认证功能
client002: ssh client first-time enable
STelnet客户端Client001用password认证方式连接SSH服务器,输入配置的用户名和密码。
[~client001]stelnet 1.1.1.1
Trying 1.1.1.1 ...
Press CTRL + K to abort
Connected to 1.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 1.1.1.1. Please wait...
Please input the username: client001
Enter password:
Warning: The initial password poses security risks.
The password needs to be changed. Change now? [Y/N]:n
Info: The max number of VTY users is 5, the number of current VTY users online i
s 1, and total number of terminal users online is 2.
The current login time is 2019-10-21 18:27:09.
The last login time is 2019-10-21 18:23:56 from 1.1.2.2 through SSH.
STelnet客户端Clent002用ECC认证方式连接SSH服务器。
[~client002]stelnet 1.1.1.1
Trying 1.1.1.1 ...
Press CTRL + K to abort
Connected to 1.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 1.1.1.1. Please wait...
Please input the username: client002
Info: The max number of VTY users is 5, the number of current VTY users online is 1, and total number of terminal users online is 2.
The current login time is 2019-10-21 18:10:59.
如果登录成功,用户将进入用户视图。如果登录失败,用户将收到Session is disconnected的信息。
- 验证配置结果
配置完成后,在SSH服务器端执行display ssh server status命令、display ssh server session,可以查看到STelnet服务已经使能,并且STelnet客户端已经成功连接到SSH服务器。
查看SSH状态信息。
dis ssh server status SSH Version : 2.0 SSH authentication timeout (Seconds) : 60 SSH authentication retries (Times) : 3 SSH server key generating interval (Hours) : 0 SSH version 1.x compatibility : Disable SSH server keepalive : Enable SFTP IPv4 server : Disable SFTP IPv6 server : Disable STELNET IPv4 server : Enable STELNET IPv6 server : Enable SNETCONF IPv4 server : Disable SNETCONF IPv6 server : Disable SNETCONF IPv4 server port(830) : Disable SNETCONF IPv6 server port(830) : Disable SCP IPv4 server : Disable SCP IPv6 server : Disable SSH server DES : Disable SSH IPv4 server port : 22 SSH IPv6 server port : 22 SSH server source address : 0.0.0.0 SSH ipv6 server source address : 0::0 SSH ipv6 server source vpnName : ACL name : ACL number : ACL6 name : ACL6 number : SSH server ip-block : Enable
查看SSH服务器的连接信息。
dis ssh server session -------------------------------------------------------------------------------- Session : 1 Conn : VTY 0 Version : 2.0 State : Started Username : client001 Retry : 1 CTOS Cipher : aes256-ctr STOC Cipher : aes256-ctr CTOS Hmac : hmac-sha2-256 STOC Hmac : hmac-sha2-256 CTOS Compress : none STOC Compress : none Kex : diffie-hellman-group14-sha1 Public Key : ECC Service Type : stelnet Authentication Type : password Connection Port Number : 22 Idle Time : 00:00:00 Total Packet Number : 147 Packet Number after Rekey : 147 Total Data(MB) : 0 Data after Rekey(MB) : 0 Time after Session Established(Minute) : 1 Time after Rekey(Minute) : 1 --------------------------------------------------------------------------------
查看SSH用户信息。
display ssh user-information -------------------------------------------------------------------------------- User Name : client001 Authentication-Type : password User-public-key-name : User-public-key-type : - Sftp-directory : Service-type : stelnet User Name : client002 Authentication-Type : ecc User-public-key-name : ecckey001 User-public-key-type : - Sftp-directory : Service-type : stelnet -------------------------------------------------------------------------------- Total 2, 2 printed



