Cisco switch password recovery walks through the full process of regaining enable mode access on a switch when the enable secret password has been lost or forgotten.
Switch Password Recovery
Let's talk about, on a switch, if you were to get into the switch but you forgot your enable mode and you couldn't figure out what your password was to get into this switch, what would you do?
Well, thankfully there is a process for this, and the process first of all starts by unplugging the switch, powering it down, holding the mode key and then plugging it back in. What that's going to do is it's going to get into the password recovery mode, in which case we can tell it to bypass; we're going to rename a config file to bypass the configuration file, so when it boots up it'll be a fresh image. Then we will get into the enable mode and then restore the configuration. So then we're in the enable mode but with the same configuration, and we just need to make a couple alterations and then we are good to go.
I'm going to restart this switch and get into that recovery mode so that we can recover this password.
Now that we're in the password recovery mode, we can configure the file, or change the file, so it doesn't boot to it. What we're going to do is, first of all, we have to initialize the flash, so we type in flash_init to initialize it. It's going through the initialization process, and we'll wait a second here until it can access the flash.
The next thing we're going to do is we're going to take a look at the directory of flash, so we can type in dir flash and hit that. The file that it actually loads for the start config is this config.text. So what we're going to do is we're going to change the name of this, so instead of loading the configurations it's just going to act as if there weren't configurations there.
So we have to rename that file. To do that we type in rename, and then flash and the file name config.text, and then we type in the new name, so flash colon config.text, and we'll just call this old. Then we'll hit enter, and then let's see what it looks like at this point. So we're going to look at the directory of flash, and there you have it, now that file is renamed, and so it's not going to boot that configuration file during the boot up process.
The next step is to reboot the switch, so we're going to just type in boot and hit enter. Then this switch is going to boot up, it's going to load up the IOS, it's going to not find that config.txt file, and so then it will boot up without any configurations.
All right, now that our switch is booted up, let's go ahead and take a look and see what happens. We get into it. The first question to ask us is do we want to do initial configuration. No we don't, because we're going to actually have our initial configurations set into here. I type in enable, I'm able to get into the enable mode, now the privilege exec mode. So I'm in there. I'm going to do a show run; you can see that the configuration file that it builds is just a blank configuration file, there's nothing to it.
So the next thing that I need to do is I need to load that up. I'm going to do a show flash, and we can see there is the old configuration file. If I wanted to, I could rename it: config.text.old, and the new name config.text, and yes, that is the destination file name. So we hit enter, and let's see what it looks like now. We'll just do a dir this time. There it is, it's renamed.
So the next thing that I want to do is I want to load that file up, so I'm going to do a copy. Copy is the command where I want to copy it from, so it's that flash config.text. And where do I want it to go to? I want it to go to the running config, and confirm it, yes. And then let's do a show run at this point in time. All right, there it is. So we now have configurations set up on this device that we had before.
So now, what if I were to save this right now and do a restart? I'd still be lost, because I still don't know the password. So let's change the password. I'm going to do enable secret, and then we'll do secure to, hit enter. Oops, I need to be in the global config mode though, so let's go into the global config mode: enable secret secure two.
And so now that is configured on that device. I need to save this, so I'm going to end, and then we're going to write it out. It's going to save the configuration, and now I can restart this and I'm safe, because my new password is known, it's secure too.
So there you have it. That is how to recover if you lose your password and you can't get into enable mode: you can go to that recovery and get into your device.
TechKnowSurge builds IT and cybersecurity professionals through hands-on, concept-first training built around real understanding — not memorization. Free interactive tools, structured programs, and 25+ years of real-world experience, all in one place.
Explore free tools and programs →