PC向路由器认证RSA,场景
1、配置dhcp server和PC机IP地址,PC机以虚拟机替代
interface GigabitEthernet0/0/0
ipaddress 192.168.100.254 255.255.255.0
dhcpselect interface
dhcpserver excluded-ip-address 192.168.100.1 192.168.100.10
dhcpserver excluded-ip-address 192.168.100.200 192.168.100.253
dhcpserver lease day 0 hour 1 minute 0
dhcpserver dns-list 221.11.132.2 221.11.132.3
dhcpserver domain-name huawei.com
2、启用接口认证
user-interface vty 0 4
authentication-mode aaa
userprivilege level 15
protocol inbound ssh
user-interface vty 16 20
3、启用AAA认证
[ar1]aaa
[ar1-aaa]local root password cipherAdmin@123 idle-timeout 20
[ar1-aaa]local root service-type ssh
4、启用Stelnet服务
[ar1]stelnet server enable
5、生成RSA本地密钥
[ar1]rsa local-key-pair create
The key name will be: Host
% RSA keys defined for Host already exist.
Confirm to replace them? (y/n)[n]:y
The range of public key size is (512 ~2048).
NOTES: If the key modulus is greater than512,
It will take a few minutes.
Input the bits in the modulus[default =512]:1024
Generating keys...
.++++++
.............++++++
.........................++++++++
....++++++++
6、虚拟机生成RSA密钥,注意
6.1、测试就选择了1024位数的密钥,越大越好
6.2、使用SSH-2 RSA密钥类型
6.3、密钥密码,是使用该密钥的个人密码,防止本机被其他人误用,下图中的红框部分
6.4、保存公钥和私钥
将公钥命名为public,私钥命名为private.ppk,测试的话就保存在本机的桌面上了
7、转换RSA公钥格式
putty默认的RSA密钥是openssh格式的,和华为路由器不兼容,但是高端的华为路由器是可以修改密钥类型为openssl的,命令是:rsa peer-public-key coding来修改为openssh格式。由于eNSP版本太低,不支持openssh格式密钥,所以不可以直接使用putty生成的密钥
那是不是就无法在eNSP上验证PC RSA登陆了呢,当然不是,要不今天写这个干嘛?我当时也遇到这个密钥转换的问题,也想到用openssl.exe转换格式,但是能力有限,今天要用到的这个小工具是windows上的sshkey.exe,下面就用它转换密钥格式
在虚拟机上,桌面已经有了sshkey.exe程序,打开它,找到前面保存的公钥public文件,
将转换后的结果,即蓝底部分复制备用
8、路由器上保存PC的公钥
[ar1]rsa peer-public-key test
Enter "RSA public key" view,return system view with "peer-public-key end".
NOTE: The number of the bits of public keymust be between 769 and 2048.
[ar1-rsa-public-key]public-key-code begin
Enter "RSA key code" view, returnlast view with "public-key-code end".
[ar1-rsa-key-code]30818702 81810096D2F89370 C0218C76 72C465BD 9FEF853D
[ar1-rsa-key-code]68266441 402C1E66A4A2735B 45006A16 99522B9F 8CAC3346
[ar1-rsa-key-code]BEC4AE9B 4D6675E009542394 85602340 C2245586 C78640CE
[ar1-rsa-key-code]31231630 52BD73D6587D1D7E 73D53876 EE923DB2 C4A753CE
[ar1-rsa-key-code]61520674 FFE735603FBFB3FD ED38794B 90EDA281 ED189231
[ar1-rsa-key-code]B8E24306 70D870DA0BC030BB 1EC6FF02 0125
[ar1-rsa-key-code]public-key-code end
[ar1-rsa-public-key]peer-public-key end
9、指定路由器上的用户使用RSA认证
[ar1]ssh user root assign rsa-key test
[ar1]ssh user root authentication-type rsa
10、在虚拟机上验证RSA登陆路由器
10.1、在虚拟机上打开putty,输入路由器IP地址
10.2、使用putty之前生成的私钥验证,注意用的是private.ppk这个之前生成的私钥文件哦
10.3、认证的时候会提示保存公钥文件,点“是”即可
10.4、登陆成功
原文地址:http://17766991309.blog.51cto.com/1668507/1898645