溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

華為SSH應(yīng)用第二篇-PC向路由器認(rèn)證RSA公鑰

發(fā)布時間:2020-08-04 11:49:21 來源:網(wǎng)絡(luò) 閱讀:1821 作者:HappyLN 欄目:網(wǎng)絡(luò)安全

PC向路由器認(rèn)證RSA,場景

華為SSH應(yīng)用第二篇-PC向路由器認(rèn)證RSA公鑰


1、配置dhcp serverPC機(jī)IP地址,PC機(jī)以虛擬機(jī)替代

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、啟用接口認(rèn)證

user-interface vty 0 4

 authentication-mode aaa

 userprivilege level 15

 protocol inbound ssh

user-interface vty 16 20

 

3、啟用AAA認(rèn)證

[ar1]aaa

[ar1-aaa]local root password cipherAdmin@123 idle-timeout 20

[ar1-aaa]local root service-type ssh

 

4、啟用Stelnet服務(wù)

[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、虛擬機(jī)生成RSA密鑰,注意

6.1、測試就選擇了1024位數(shù)的密鑰,越大越好

6.2、使用SSH-2 RSA密鑰類型

6.3、密鑰密碼,是使用該密鑰的個人密碼,防止本機(jī)被其他人誤用,下圖中的紅框部分

華為SSH應(yīng)用第二篇-PC向路由器認(rèn)證RSA公鑰


6.4、保存公鑰和私鑰

華為SSH應(yīng)用第二篇-PC向路由器認(rèn)證RSA公鑰


將公鑰命名為public,私鑰命名為private.ppk,測試的話就保存在本機(jī)的桌面上了


7、轉(zhuǎn)換RSA公鑰格式

putty默認(rèn)的RSA密鑰是openssh格式的,和華為路由器不兼容,但是高端的華為路由器是可以修改密鑰類型為openssl的,命令是:rsa peer-public-key coding來修改為openssh格式。由于eNSP版本太低,不支持openssh格式密鑰,所以不可以直接使用putty生成的密鑰

 

那是不是就無法在eNSP上驗證PC RSA登陸了呢,當(dāng)然不是,要不今天寫這個干嘛?我當(dāng)時也遇到這個密鑰轉(zhuǎn)換的問題,也想到用openssl.exe轉(zhuǎn)換格式,但是能力有限,今天要用到的這個小工具是windows上的sshkey.exe,下面就用它轉(zhuǎn)換密鑰格式

 

在虛擬機(jī)上,桌面已經(jīng)有了sshkey.exe程序,打開它,找到前面保存的公鑰public文件,

華為SSH應(yīng)用第二篇-PC向路由器認(rèn)證RSA公鑰


將轉(zhuǎn)換后的結(jié)果,即藍(lán)底部分復(fù)制備用

 

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認(rèn)證

[ar1]ssh user root assign rsa-key test

[ar1]ssh user root authentication-type rsa

 

10、在虛擬機(jī)上驗證RSA登陸路由器

10.1、在虛擬機(jī)上打開putty,輸入路由器IP地址

華為SSH應(yīng)用第二篇-PC向路由器認(rèn)證RSA公鑰


10.2、使用putty之前生成的私鑰驗證,注意用的是private.ppk這個之前生成的私鑰文件哦

華為SSH應(yīng)用第二篇-PC向路由器認(rèn)證RSA公鑰


10.3、認(rèn)證的時候會提示保存公鑰文件,點(diǎn)“是”即可

華為SSH應(yīng)用第二篇-PC向路由器認(rèn)證RSA公鑰


10.4、登陸成功


向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI