实验目标
- 配置R1与R3之间的RSA密钥交换,使得R1可以通过stelnet方式安全地访问R3。
- 配置R2通过使用密码登录,使得R2可以通过stelnet方式安全地访问R3。
- 了解了RSA密钥交换和密码验证方式在实际中的应用,加深了对这些知识点的理解。
实验环境
- 设备:ensp下的路由器R1,R2,R3和交换机。
- 连接:R1的G0/0/0口连着交换机的G0/0/1口,R2的G0/0/0口连着交换机的G0/0/2口,R3的G0/0/0口连着交换机的G0/0/3口。
实验步骤
- 生成RSA密钥对:在R1和R3上生成RSA密钥对,并在两设备之间交换公钥。
- 配置R3以接受R1和R2的stelnet访问
- 验证实验结果,分别在R1和R2上通过stelnet连接到R3。
1.在R1和R3上生成RSA密钥对并在两者之间交换公钥。
在R1上创建RSA密钥对
[r1]rsa local-key-pair create
Confirm to replace them? (y/n)[n]:y
Input the bits in the modulus[default = 512]:512 //选择适当的参数
Generating keys...
..........................++++++++++++
............................++++++++++++
...........++++++++
..............................++++++++ //密钥创建成功
在R3上创建RSA密钥对
[r3]rsa local-key-pair create
Confirm to replace them? (y/n)[n]:y
Input the bits in the modulus[default = 512]:512 //选择适当的参数
Generating keys...
..........................++++++++++++
............................++++++++++++
...........++++++++
..............................++++++++ //密钥创建成功
导出R1和R3的公钥,并分别在对方设备上导入。
[r1]dis rsa local-key-pair public //查看R1的公钥
注:
在华为设备上使用
dis rsa local-key-pair public
命令时,会显示两种类型的公钥:主机(Host)和服务器(Server)。这两种公钥都可以用于进行SSH或者其他基于公钥的服务。一般情况下,"Host"类型的公钥用于设备的SSH服务,即当设备作为SSH服务器时使用。"Server"类型的公钥通常用于设备作为其他服务(例如SSL VPN)的服务器时使用。
复制R1上Host类型公钥中的Key code
=====================================================
Time of Key pair created: 2023-07-30 15:33:02-08:00
Key name: Host
Key type: RSA encryption Key
=====================================================
Key code:
3047
0240
BC43F2C0 4E28FAFA 871B9E12 B5848F91 0A17E779
3BD00786 746A1EB6 9E7E9D1C 1EDC8D3C 9BB035FA
3A2FAAA2 5ED548E0 BAF6CA75 E73AC4F7 0B67FB74
50DEC2DB
0203
010001
=====================================================
在R3上添加R1的公钥
[r3]rsa peer-public-key R1
[r3-rsa-public-key]public-key-code begin
[r3-rsa-key-code]3047
[r3-rsa-key-code] 0240
[r3-rsa-key-code] BC43F2C0 4E28FAFA 871B9E12 B5848F91 0A17E779
[r3-rsa-key-code] 3BD00786 746A1EB6 9E7E9D1C 1EDC8D3C 9BB035FA
[r3-rsa-key-code] 3A2FAAA2 5ED548E0 BAF6CA75 E73AC4F7 0B67FB74
[r3-rsa-key-code] 50DEC2DB
[r3-rsa-key-code] 0203
[r3-rsa-key-code] 010001
[r3-rsa-key-code]public-key-code end
[r3-rsa-public-key]peer-public-key end
同样的做法,在R1上添加R3的公钥
[r1]rsa peer-public-key R3
[r1-rsa-public-key]public-key-code begin
[r1-rsa-key-code]3047
[r1-rsa-key-code] 0240
[r1-rsa-key-code] C7838BAB 1D045DF3 02F13756 02594145 800F0732
[r1-rsa-key-code] 4D9CDC3E CBBCAF4B B09A9AF7 71C0CD37 C5CD45B8
[r1-rsa-key-code] 6DC6F358 F67BFFEA 8F8277BA 242CAC66 8536FD78
[r1-rsa-key-code] 378D0205
[r1-rsa-key-code] 0203
[r1-rsa-key-code] 010001
[r1-rsa-key-code]public-key-code end
[r1-rsa-public-key]peer-public-key end
2.配置R3以接受R1和R2的stelnet访问
在R3上开启stelnet功能
[r3]stelnet server enable
进入aaa试图,创建一个用户
[r3]aaa
[r3-aaa]local-user ff service-type ssh
[r3-aaa]local-user ff privilege level 15 //配置用户权限等级
为SSH用户"ff"分配RSA密钥,密钥的名称是"R1",将此用户的身份验证类型设置为RSA
[r3]ssh user ff assign rsa-key R1
[r3]ssh user ff authentication-type rsa
进入设备的虚拟终端(Virtual Terminal,VTY)用户界面配置模式,设置用户登录验证方式(authentication-mode
)和限制能够访问设备的远程登录协议为SSH
[r3]user-interface vty 0 4
[r3-ui-vty0-4]authentication-mode aaa
[r3-ui-vty0-4]protocol inbound ssh
到此,R1和R3就可以使用RSA 密钥交换的方式,使得R1可以通过stelnet方式安全地访问R3了
下面来配置R2通过使用密码登录的方式来安全访问R3
在R3上,进入aaa视图,增添一个用户,并配置权限,服务类型等参数
[r3]aaa
[r3-aaa]local-user password_user password cipher 207673
[r3-aaa]local-user password_user privilege level 15
[r3-aaa]local-user password_user service-type ssh
到此,R2和R3就可以使用密码登录的方式,使得R2可以通过stelnet方式安全地访问R3了
3.验证实验结果,分别在R1和R2上通过stelnet连接到R3。
在某些华为设备上,默认情况下SSH客户端在首次使用时可能是禁用的。如果你尝试使用SSH客户端进行远程登录,而SSH客户端没有被启用,那么设备将会拒绝SSH请求。为了避免这种情况,你可以使用ssh client first-time enable
命令来提前启用SSH客户端。
在R1上执行stelnet 192.168.0.3
命令,验证是否可以通过RSA密钥交换方式进行stelnet访问R3。
[r1]ssh client first-time enable
[r1]stelnet 192.168.0.3
Please input the username:ff
Trying 192.168.0.3 ...
Press CTRL+K to abort
Connected to 192.168.0.3 ...
The server is not authenticated. Continue to access it? (y/n)[n]:y
Jul 30 2023 16:09:27-08:00 r1 %%01SSH/4/CONTINUE_KEYEXCHANGE(l)[2]:The server had not been authenticated in the process of exchanging keys. When deciding whether to continue, the user chose Y.
[r1]
Save the server's public key? (y/n)[n]:y
The server's public key will be saved with the name 192.168.0.3. Please wait...
Jul 30 2023 16:09:28-08:00 r1 %%01SSH/4/SAVE_PUBLICKEY(l)[3]:When deciding whether to save the server's public key 192.168.0.3, the user chose Y.
[r1]
<r3>
在R2上执行stelnet 192.168.0.3
命令,验证是否可以通过密码方式进行stelnet访问R3。
[r2]ssh client first-time enable
[r2]stelnet 192.168.0.3
Please input the username:password_user
Trying 192.168.0.3 ...
Press CTRL+K to abort
Connected to 192.168.0.3 ...
The server is not authenticated. Continue to access it? (y/n)[n]:y
Jul 30 2023 16:16:14-08:00 r2 %%01SSH/4/CONTINUE_KEYEXCHANGE(l)[0]:The server had not been authenticated in the process of exchanging keys. When deciding whether to continue, the user chose Y.
[r2]
Save the server's public key? (y/n)[n]:y
The server's public key will be saved with the name 192.168.0.3. Please wait...
Jul 30 2023 16:16:22-08:00 r2 %%01SSH/4/SAVE_PUBLICKEY(l)[1]:When deciding whether to save the server's public key 192.168.0.3, the user chose Y.
[r2]
Enter password:
<r3>
实验注意事项
实际操作中需要根据具体的网络环境和设备来调整和设置相应的参数和配置。在进行实验前,确保所有设备的IP地址和接口配置正确,并且网络连通性良好。
实验总结
在这个实验中,我们的目标是实现R1通过RSA密钥交换进行stelnet访问R3,以及R2通过密码方式进行stelnet访问R3。
首先,我们在R1和R3上生成RSA密钥对并在两者之间交换公钥。然后在R3上配置了接受R1和R2的stelnet访问,其中R1使用RSA方式,R2使用密码方式。在配置完成后,R1和R2通过stelnet命令连接到R3进行验证。
以下是实验步骤的总结:
- 在R1和R3上生成RSA密钥对并在两者之间交换公钥。
- 配置R3以接受R1的stelnet访问,身份验证方式为RSA。
- 配置R3以接受R2的stelnet访问,身份验证方式为密码。
- 验证实验结果,分别在R1和R2上通过stelnet连接到R3。
在验证实验结果时,我们发现R1和R2都能成功通过stelnet连接到R3,其中R1使用RSA密钥交换,R2使用密码。这说明我们的配置是成功的。
实验过程中,需要注意的是需要根据实际的网络环境和设备来调整和设置相应的参数和配置,并在实验前后确保网络连通性良好,避免出现ping不通等问题。文章来源:https://www.toymoban.com/news/detail-766552.html
通过这个实验,我们学习了如何配置并验证stelnet连接,了解了RSA密钥交换和密码验证方式在实际中的应用,加深了对这些知识点的理解。文章来源地址https://www.toymoban.com/news/detail-766552.html
到了这里,关于使用RSA密钥交换和密码验证进行安全的stelnet远程登录配置实验(华为ensp实现)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!