Cisco Switch Recovery and Factory Reset

Need to configure a Cisco switch and don’t know the password? This is how you get in to a  Cisco switch config if you don’t know the password or want to erase the configuration and reset back to factory setting. I would always reset any switch before selling it etc.

putty

Connect to the switch via console with Putty. If you have issues connecting check your USB port number in device manager.

Press and hold the mode button while powering on.  You can realse the button when you get to the switch: command prompt.

Boot Sector Filesystem (bs) installed, fsid: 2
Base ethernet MAC Address: c4:71:fe:2c:2e:00
Xmodem file system is available.
The password-recovery mechanism is enabled.
The system has been interrupted prior to initializing the flash filesystem.
The following commands will initialize the flash filesystem, and finish loading the operating system software:

flash_init

boot

switch:

Initialize the flash file system with the command ‘flash_init’

switch:flash_init
Initializing Flash…
flashfs[0]: 528 files, 19 directories
flashfs[0]: 0 orphaned files, 0 orphaned directories
flashfs[0]: Total bytes: 32514048
flashfs[0]: Bytes used: 10419200
flashfs[0]: Bytes available: 22094848
flashfs[0]:
flashfs fsck took 11 seconds.
 …done Initializing Flash.

switch:

Let’s see what files are in flash with the command ‘dir flash:’

switch: dir flash:

Directory of flash:/

2 -rwx 916 <date> vlan.dat
5 drwx 192 <date> c2960-lanbase-mz.122-25.SEE1
620 -rwx 5488 <date> config.text
621 -rwx 5 <date> private-config.text

24800256 bytes available (7713792 bytes used)

If you want to keep the config and bypass the password we have to rename the config.text file, then boot up and then reload it afterwards. It’s quite simple to complete.

OK, now rename the config.text so we can use it later.

switch: rename flash:config.text flash:config.text.old

Let’s reboot this sucker. It will now boot up in factory default setting with no config.

switch: boot

Loading “flash:c2960-lanbase-mz.122-25.SEE1/c2960-lanbase-mz.122-25.SEE1.bin”…
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

We change the name of the config.text again.

Switch> enable

Switch# rename flash:config.text.old flash:config.text

Destination filename [config.text]? <Enter>

Nearly there now….just copy the config to the running config.

Switch# copy flash:config.text system:running-config

Destination filename [running-config]?<Enter>

That’s it. You now have bypassed the password and can look and change the config. You can also change the password to something you can remember.

To just wipe the switch back to factory default is basically the same procedure.

switch: dir flash:

Directory of flash:/
2 -rwx 916 <date> vlan.dat
5 drwx 192 <date> c2960-lanbase-mz.122-25.SEE1
620 -rwx 5488 <date> config.text
621 -rwx 5 <date> private-config.text

24800256 bytes available (7713792 bytes used)

Delete the config.text and vlan.dat files.

switch:del flash:config.text
Are you sure you want to delete “flash:config.text” (y/n)?y
File “flash:config.text” deleted
switch:del flash:vlan.dat
Are you sure you want to delete “flash:vlan.dat” (y/n)?y
File “flash:vlan.dat”
switch:boot

That’s it. Just boot the switch back up to check the config has been deleted and you are done!

  • Was this Helpful ?
  • yes   no

satoms Author

Leave a Reply

Your email address will not be published. Required fields are marked *