密码恢复原理:

一般CISCO交换机的主配置文件(包括了密码,用户,策略,设定等等)为config.text ,所以我们要做的是在设备启动时候绕过闪存里的这个config.text 从而直接进入交换机的配置界面,而此时不论你进入全局模式,还是特权模式,都是不需要密码的.当你进入特权模式后,再将重新导入config.text 文件到flash里,然后再修改当前的密码,接着重启后就可以用新的密码进入特权模式了,而且原先的配置内容也都保留着.
 1.对于Catalyst 2900/3500XL系列来说:
拔下交换机的电源线,然后按住交换机的Mode按钮,再重新插上交换机的电源线.直到端口Port 1x的LED熄灭之后释放Mode按钮.
就这么简单,别告诉我你不知道Mode按钮在哪啊-_-#


2.对于Catalyst 2940/2950L系列来说:
拔下交换机的电源线,然后按住交换机的Mode按钮,再重新插上交换机的电源线.直到STAT的LED熄灭之后释放Mode按钮.

3.对于Catalyst 2955系列来说:
Catalyst 2955没有没有外部的Mode按钮,因此就不能使用之前的那种方法来进行密码恢复.在交换机启动时,对于Windows系列的PC,按下Ctrl+Break键;对于UNIX系列的工作站,按下Ctrl+C..如下:

  C2955 Boot Loader (C2955−HBOOT−M) Version 12.1(0.0.514), CISCO DEVELOPMENT TEST
VERSION
Compiled Fri 13−Dec−02 17:38 by madison
WS−C2955T−12 starting...
Base ethernet MAC Address: 00:0b:be:b6:ee:00
Xmodem file system is available.

Initializing Flash...
flashfs[0]: 19 files, 2 directories
flashfs[0]: 0 orphaned files, 0 orphaned directories
flashfs[0]: Total bytes: 7741440
flashfs[0]: Bytes used: 4510720
flashfs[0]: Bytes available: 3230720
flashfs[0]: flashfs fsck took 7 seconds.
...done initializing flash.
Boot Sector Filesystem (bs:) installed, fsid: 3
Parameter Block Filesystem (pb:) installed, fsid: 4
/---接下来交换机会在15秒内自动启动,等出现该信息之后,按下Ctrl+Break键或Ctrl+C键----/

The system has been interrupted prior to initializing the flash file system to finish
loading the operating system software:
flash_init
load_helper
bootswitch:

操作步骤:
1、准备好console线缆,超级终端连接好.
2、重启交换机(由于2950没有电源开关,所以直接把电源线拔掉再接回去就OK)
3、 刚开始启动时按下MODE键,就可以进入switch模式了,注意:这里动作要快一点,否则进入正常模式就没有用了。
4、上面启动完成后,可以看到switch:的提示符了,不同于正常模式的switch>,以及上面的三个命令。
switch: flash_init                                //初始化flash
switch: dir flash:                              //初始化之后就可以看到flash里的文件了
Directory of flash:/
2    -rwx  796       <date>               vlan.dat
3    -rwx  2597      <date>               satrat
6    drwx  192       <date>               c2960-lanbase-mz.122-25.SEE3
621  -rwx  3137      <date>               stgart
622  -rwx  2601      <date>               config.text
623  -rwx  5         <date>               private-config.text
24793088 bytes available (7720960 bytes used)
运行配置以及密码等信息就保存在config.text中
switch: rename flash:config.text flash:config-old.text   //重命名配置文件,可以让下次启动时绕过config.text文件
switch: dir flash:
Directory of flash:/
2    -rwx  796       <date>               vlan.dat
3    -rwx  2597      <date>               satrat
6    drwx  192       <date>               c2960-lanbase-mz.122-25.SEE3
621  -rwx  3137      <date>               stgart
622  -rwx  2601      <date>               config-old.text
623  -rwx  5         <date>               private-config.text
24793088 bytes available (7720960 bytes used)
switch: reset       //重启交换机
Are you sure you want to reset the system (y/n)?y
System resetting...
Would you like to terminate autoinstall? [yes]:   //中断自动配置 确认
Would you like to enter the initial configuration dialog? [yes/no]: no  //选择不进入对话交互式配置模式
Switch>enable                                                                  //进入特权模式
Switch# copy config-old.text running-config                  //将之前的配置文件载入

Destination filename [running.config]?
Copy in progress...C
2601 bytes copied in 0.026 secs (100038 bytes/sec)
这里我们可以用
no enable password
no enable secrect
把密码删除,也可以按照自己的要求重新修改密码
Switch#config termial                                         //进入配置模式,进行密码设定
一.设置console密码
>enable
#configure terminal
(confing)#line console 0←console口
(config-line)#password   (cisco)←密码
(config-line)#login ← 一定不能少的.
console密码设置完成
exit
二:设置全局密码
enadle
#configure terminal
(config)#enable secret (class)←密码
(config)#login
全局密码设置完成
exit
三.设置远程登入(telnet)密码
enable
#config terminal
(config)#line vty 0 4(0 4是口)
(config-line)#password (class)←密码
(config-lline)#login
Switch#copy running-config startup-config           //最后千万不要忘记保存配置重新启动即可