HUAWEI網路裝置恢復Console口密碼

上古南城發表於2022-01-14

密碼遺忘

本章介紹了Console口丟失的處理方法,建議使用者妥善保管密碼,並定期修改。

恢復Console口密碼

裝置提供如下方法恢復Console口密碼。
•方法一:通過STelnet/Telnet登入裝置修改Console口密碼。(推薦)
•方法二:在BootROM下配置清除Console口密碼啟動後,修改Console口密碼。
•方法三:在BootROM選單下取消設定下次啟動配置檔案,裝置以空配置啟動後修改Console口密碼。

方法一:通過STelnet/Telnet登入裝置修改Console口密碼。

以下涉及的命令列及回顯資訊以STelnet登入裝置修改Console口密碼為例。如果使用者擁有STelnet賬號,並且具有3級或更高的許可權,則可以通過STelnet登入到裝置後修改Console口密碼,然後儲存配置。


1.使用STelnet賬號登入裝置,並確認當前賬號有3級或更高的許可權。
使用display users命令檢視當前裝置所有登入使用者。其中帶“+”標記行為當前使用者,記錄對應的編號VTY1。

<HUAWEI> display users
  User-Intf    Delay    Type   Network Address     AuthenStatus    AuthorcmdFlag
  129 VTY 0   00:23:36  TEL    10.135.18.67              pass           no        Username : Unspecified

+ 130 VTY 1   01:20:36  TEL    10.135.18.91              pass           no        Username : Unspecified

  131 VTY 2   00:00:00  TEL    10.135.18.54              pass           no        Username : Unspecified

使用display user-interface命令可以顯示所有使用者的許可權,確定VTY1對應的等級為15,有許可權修改Console口密碼。

<HUAWEI> display user-interface
  Idx  Type     Tx/Rx      Modem Privi ActualPrivi Auth  Int
  0    CON 0    9600       -     15    -           P     -
+ 129  VTY 0               -     15    15          P     -
+ 130  VTY 1               -     15    15          P     -
+ 131  VTY 2               -     15    -           P     -
  132  VTY 3               -     15    15          P     -
......

 2.修改Console使用者的密碼,以修改為密碼認證,密碼為“huawei@123”為例。

<HUAWEI> system-view
[HUAWEI] user-interface console 0
[HUAWEI-ui-console0] authentication-mode password
[HUAWEI-ui-console0] set authentication password cipher huawei@123
[HUAWEI-ui-console0] return

 3.為了防止重啟後配置丟失,儲存配置。

<HUAWEI> save
The current configuration will be written to the device.
Are you sure to continue?[Y/N]y
Now saving the current configuration to the slot 0.
Save the configuration successfully.

 方法二:在BootROM下清除Console口密碼登入後,修改Console口密碼。

裝置的BootROM提供了清除Console口密碼的功能,可以在使用者使用Console口登入的時候跳過密碼檢查。這樣系統啟動後除了不需要輸入Console密碼外,與正常啟動相同,也會完成所有配置載入。裝置啟動後重新配置驗證方式和Console口密碼,然後儲存配置。

注意:
•要進入到BootROM選單需要重啟裝置,會導致業務中斷,請視具體情況做好裝置備份,並儘量選擇業務量較少的時間操作。
•清除Console口密碼登入後請馬上配置新的密碼。
•在此操作過程中不要對裝置進行下電。

1.用串列埠線連線裝置,然後重啟。當出現“Press Ctrl+B to enter BootROM menu...”(V200R002及V200R003版本)或者“Press Ctrl+B or Ctrl+E to enter BootROM menu ...”(V200R005及以後釋出的版本)列印資訊時,按下“Ctrl+B”或者“Ctrl+E”並鍵入密碼(預設為“Admin@huawei.com”,V100R006C03之前版本可能為“huawei”),進入BootROM主選單。
2.清除Console口登入密碼。

          BootROM  MENU

    1. Boot with default mode
    2. Enter serial submenu
    3. Enter startup submenu
    4. Enter ethernet submenu
    5. Enter filesystem submenu
    6. Modify BootROM password   //V200R006及之前版本:Modify BootROM password V200R007及之後版本:Enter password submenu
    7. Clear password for console user
    8. Reboot
    (Press Ctrl+E to enter diag menu) 

Enter your choice(1-8): 7

Note: Clear password for console user? Yes or No(Y/N): y

Clear password for console user successfully. Choose "1" to boot, then set a new password.
Note: Do not choose "8. Reboot" or power off the device, otherwise this operation will not take effect.

 3.根據裝置的提示,在BootROM主選單下選擇“1”啟動裝置。
4.完成系統啟動後,通過Console口登入時不需要認證,登入後配置Console口密碼,以修改為密碼認證,並修改密碼為“huawei@123”為例。

<HUAWEI> system-view
[HUAWEI] user-interface console 0
[HUAWEI-ui-console0] authentication-mode password
[HUAWEI-ui-console0] set authentication password cipher huawei@123
[HUAWEI-ui-console0] return

 5.為了防止重啟後配置丟失,儲存配置。

<HUAWEI> save
The current configuration will be written to the device.
Are you sure to continue?[Y/N]y
Now saving the current configuration to the slot 0.
Save the configuration successfully.

 方法三:在BootROM選單下取消設定下次啟動配置檔案,裝置以空配置啟動後修改Console口密碼。

在BootROM下取消設定下次啟動配置檔案,裝置會以空配置(出廠配置)啟動。啟動後將原配置檔案匯出,手動修改其中關於Console口登入的配置。將修改後的配置檔案重新上傳至裝置,配置裝置以修改後的配置檔案啟動,重啟後的裝置將無需輸入Console口登入密碼。(以下舉例以Console口下配置了Password認證為例,其它認證方式以裝置實際情況為準。)

 注意:
•要進入到BootROM選單需要重啟裝置,會導致業務中斷,請視具體情況做好裝置備份,並儘量選擇業務量較少的時間操作。
•在此操作過程中不要對裝置進行下電。
•V200R010及之後版本Console口預設為AAA認證,如果空配置啟動後沒有修改認證方式,配置裝置以刪除認證方式後的配置檔案啟動時,重啟後的裝置需要輸入預設的使用者名稱admin和密碼admin@huawei.com,此種情況下的回顯,以裝置實際顯示為準。

1.用串列埠線連線裝置,然後重啟,當出現“Press Ctrl+B to enter BootROM menu...”(V200R002及V200R003版本)或者“Press Ctrl+B or Ctrl+E to enter BootROM menu ...”(V200R005及以後釋出的版本)列印資訊時,按下“Ctrl+B”或者“Ctrl+E”並鍵入密碼(預設為“Admin@huawei.com”,V100R006C03之前版本可能為“huawei”)後進入BootROM主選單。
2.清空啟動配置檔案,使裝置以空配置啟動。

          BootROM  MENU

    1. Boot with default mode
    2. Enter serial submenu
    3. Enter startup submenu
    4. Enter ethernet submenu
    5. Enter filesystem submenu
    6. Modify BootROM password   //V200R006及之前版本:Modify BootROM password V200R007及之後版本:Enter password submenu
    7. Clear password for console user
    8. Reboot
    (Press Ctrl+E to enter diag menu) 

Enter your choice(1-8): 3

       Startup Configuration Submenu

    1. Display startup configuration
    2. Modify startup configuration
    3. Return to main menu


Enter your choice(1-3): 2

Note: startup file field can not be cleared
'.'=clear field; =quit; Enter=use current configuration

startup type(1: Flash)
  current: 1
  new    :

Flash startup file (can not be cleared)
  current: HUAWEI-v200r008c00.cc
  new    :

saved-configuration file
  current: vrpcfg.zip
  new    : .          //清空當前值

patch package
  current:
  new    :

       Startup Configuration Submenu

    1. Display startup configuration
    2. Modify startup configuration
    3. Return to main menu

Enter your choice(1-3): 3     

 3.在BootROM主選單下選擇“1”啟動裝置。
4.完成系統啟動後,裝置會恢復為出廠配置。V200R009及之前版本通過Console口登入時,提示設定Console口密碼,以密碼為“huawei@123”為例。

An initial password is required for the first login via the console.
Continue to set it? [Y/N]:y
Set a password and keep it safe. Otherwise you will not be able to login via the console.

Please configure the login password (8-16)
Enter Password:     //輸入huawei@123
Confirm Password:     //再次輸入huawei@123

 V200R010及之後版本通過Console口登入時,提示輸入Console口的預設使用者名稱和密碼,之後會提示修改密碼,此時必須修改密碼,以密碼為“huawei@123”為例。

Login authentication                                                            
                                                                                
                                                                           
Username:admin                                                                  
Password:     //輸入admin@huawei.com                                                                       
Warning: The default password poses security risks.                             
The password needs to be changed. Change now? [Y/N]: y                          
Please enter old password:     //輸入admin@huawei.com                                                      
Please enter new password:     //輸入huawei@123                                                      
Please confirm new password:     //再次輸入huawei@123                                                    
The password has been changed successfully. 

 5.恢復原配置。當前裝置為預設的出廠配置,若希望恢復裝置原配置,又不想保留原配置檔案中關於Console密碼的配置,可以下載原配置檔案到PC上,手動刪除Console下配置後,上傳至裝置,指定為下次啟動檔案,重啟裝置。

a.配置裝置為FTP伺服器。

<HUAWEI> system-view
[HUAWEI] ftp server enable
Info: The FTP server is already enabled.
[HUAWEI] vlan 10
[HUAWEI-vlan10]  interface vlanif 10   //配置VLANIF10作為管理介面。
[HUAWEI-Vlanif10] ip address 10.110.24.254 24
[HUAWEI-Vlanif10] quit
[HUAWEI] interface gigabitethernet 0/0/10   //GE0/0/10為使用Web網管登入Switch的PC與Switch相連的物理介面編號,請按照實際現網情況進行選擇。
[HUAWEI-GigabitEthernet0/0/10] port link-type access
[HUAWEI-GigabitEthernet0/0/10] port default vlan 10
[HUAWEI-GigabitEthernet0/0/10] quit
[HUAWEI] aaa
[HUAWEI-aaa] local-user huawei password irreversible-cipher huawei@123
[HUAWEI-aaa] local-user huawei ftp-directory flash:
[HUAWEI-aaa] local-user huawei service-type ftp
[HUAWEI-aaa] local-user huawei privilege level 15

 b.下載原配置檔案vrpcfg.zip到PC。

C:\Documents and Setting\Administrator> ftp 10.110.24.254
連線到 10.110.24.254。
220 FTP service ready.
使用者 (10.110.24.254:(none)): huawei
331 Password required for huawei.
密碼:
230 User logged in.
ftp> get vrpcfg.zip
200 Port command okay.
150 Opening ASCII mode data connection for directory list.
226 Transfer complete.
ftp: 收到 981 位元組,用時 0.01秒 981000.00千位元組/秒.

 c.在PC上解壓後使用文字編輯工具(建議用系統自帶的文字編輯工具)開啟並刪除Console口認證配置,刪除後重新壓縮成vrpcfg.zip檔案。需刪除的配置如下所示:

#
user-interface maximum-vty 15
user-interface con 0
 authentication-mode password         //需手動刪除
 set authentication password cipher %@%@:*IB+w7j~""GlU$0-;\#m@Jw%@%@      //需手動刪除
#
user-interface con 0
 authentication-mode aaa     //需手動刪除
 user privilege level 15     //需手動刪除

 6.將修改後的配置檔案儲存後,上傳到裝置,替換原配置檔案。

ftp> put vrpcfg.zip
200 Port command okay.
150 Opening ASCII mode data connection for directory list.
226 Transfer complete.
ftp: 傳送 981 位元組,用時 0.00Seconds 978000.00千位元組/秒.

 7.設定修改後的配置檔案為下一次啟動配置檔案,選擇不儲存配置重啟裝置。

<HUAWEI> startup saved-configuration vrpcfg.zip
Info: Succeeded in setting the configuration for booting system.
<HUAWEI> reboot fast
System will reboot! Continue ? [y/n]:y

 8.重啟後,會再次提醒設定Console登入密碼,輸入一個安全並方便自己記憶的密碼後,回車,進入命令列介面。

 

相關文章