How to reset Cisco 2960 switch password without losing your configuration

To reset your Cisco 2960 password, connect your console cable to the switch and open up your terminal emulator software, you can use minicom if you are using Linux. Please visit this link on how to install and configure minicom using in Fedora/Red Hat/CentOS and this link if you are using Debian/Ubuntu.

Power on the switch while holding the mode button. Release the mode button after you see the screen below in your terminal emulator software.

Boot Sector Filesystem (bs) installed, fsid: 2       
Base ethernet MAC Address: 1c:1d:86:db:c8:80         
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:



Initialize the flash file system using the below command.

Initializing Flash...                                                           
flashfs[0]: 542 files, 19 directories                                           
flashfs[0]: 0 orphaned files, 0 orphaned directories                            
flashfs[0]: Total bytes: 32514048                                               
flashfs[0]: Bytes used: 13520384                                                
flashfs[0]: Bytes available: 18993664                                           
flashfs[0]: flashfs fsck took 11 seconds.                                       
...done Initializing Flash.

Find the config file in flash: directory

dir flash:

The files that we are looking for in the flash: directory is the config.text file.

Directory of flash:/                                                            
    3  -rwx  2296                     vlan.dat                            
    4  -rwx  3569                     config.text                         
    5  -rwx  5                        private-config.text                 
    6  drwx  192                      c2960-lanbasek9-mz.122-55.SE7       
  562  -rwx  2072                     multiple-fs     

Rename the config file so that it will not be loaded when we boot to the switch.

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

Then type the below command to boot to the switch


After booting, the switch will ask you to enter the "initial configuration dialog" to initially configure the switch using interactive CLI mode. Just type the word "no" because we are not re-configuring the switch.

         --- System Configuration Dialog ---

Enable secret warning
In order to access the device manager, an enable secret is required
If you enter the initial configuration dialog, you will be prompted for the enable secret
If you choose not to enter the intial configuration dialog, or if you exit setup without setting the enable secret,
please set an enable secret using the following CLI in configuration mode-
enable secret 0 
Would you like to enter the initial configuration dialog? [yes/no]: no

At the switch prompt type en to enter enable mode.


Rename the configuration file to its original filename.

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

Copy the configuration file into the memory

copy flash:config.text system:running-config

Now that the config is loaded in to the memory, we can start changing the password.

conf t
enable secret newpassword

After changing the password, save the config and done.

write memory

This tutorial will also work on Cisco 2950 switches. Hope this helps.