应用背景:
客户遗忘了交换机的密码
操作序列:
通过 ctrl+b 进入 Boot 模式
使用 boot startup-config null 命令,并 reboot
Img 模式下,type startup.cfg 获取原配置中的密码
Img 模式下,boot startup-config startup.cfg 将配置文件作为启动文件
具体为:
进入 boot 模式,并进行如下配置
[Boot]: boot startup-config null
看到提示信息:default factory-config will be used. 后,输入 reboot 设备重启,将以出厂配置启动。
进入 img 模式,进行如下操作
在特权模式下,输入命令 type startup.cfg,可以读取设备的配置,从而获取密码。
Switch#type startup.cfg
no service password-encryption
!
hostname Switch
sysLocation China
sysContact 400-810-9119
!
enable password level 15 0 dcn_123
!
username admin privilege 15 password 0 admin
…(省略后续部分)
如果密码为明文,则直接能够获取到;如果密码为密文,则请获取其他配置项,重新刷入配
置,密码重新配置后,write 保存。获取到密码或重新完成配置后,执行如下操作
Switch#boot startup-config startup.cfg
flash:/startup.cfg will be used as the startup-config file at the next time!
重启设备后,即还原为之前设备配置。