TechKnowSurge
Cisco CCNA 5.3 Cisco CCNA 2.8 Cisco CCST Networking 5.5
VideoNetworkFree

DEMO: Recovering from lost password, Switch

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.

Complete this video to capture a CTF flag worth 1 point.

About this video

Losing access to a Cisco switch's enable mode due to a forgotten password does not require a full factory reset or permanent loss of configuration data. A built-in recovery process makes it possible to regain privileged access while preserving the existing configuration, following a specific sequence of steps that begins before the device even finishes booting. The process starts by powering down the switch, holding the Mode button, and powering it back on to enter password recovery mode, which provides low-level access to flash memory outside of the normal IOS boot sequence. From there, flash is initialized using the flash_init command, and the directory is examined to locate the startup configuration file, config.text. That file is then renamed so the switch cannot locate it during boot, causing the device to start up as if no configuration exists. After rebooting with the boot command, the switch loads IOS without any saved configuration, and enable mode is immediately accessible without a password prompt. At that point, the renamed configuration file is visible in flash and can be renamed back to config.text. Copying that file to the running configuration restores all previous settings to the active state. The final step is entering global configuration mode to set a new enable secret password, then saving the configuration with the write command. Once the device is restarted, the recovered configuration is fully intact and protected by the newly defined password.

What you'll learn

What's covered

Switch Password Recovery

Aligned to

Cisco CCNA
5.3 Configure and verify device access control using local passwords
2.8 Describe network device management access
Cisco CCST Networking
5.5 Run basic show commands on a Cisco network device

Key terms

Switch
A network device that connects devices within a LAN and forwards traffic based on MAC addresses.
Privileged EXEC Mode
An elevated Cisco IOS CLI access level, indicated by a pound sign prompt (#), that provides full access to device monitoring and the ability to enter configuration modes.
Startup Configuration
A saved configuration file stored in NVRAM that is loaded into RAM during the boot process to configure the device's settings and parameters.
Password Recovery
A process used to regain access to a Cisco device by bypassing the startup configuration when the enable password is unknown.
Flash Memory
A type of non-volatile solid-state memory that stores data on chips and retains information without power; it is the storage technology behind SSDs, USB drives, and SD cards.
Enable Secret
A Cisco IOS command that sets an MD5-hashed password for privileged exec mode, taking precedence over enable password and stored as a hash in the running configuration.

Topics

Cisco Switch Password Recovery Privileged Exec Mode Ios Configuration Network Device Management Networking

Transcript

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.

Renaming the configuration file

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.

Rebooting the switch

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.

Restoring the configuration

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.

Setting a new password

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.

About TechKnowSurge

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 →