4. Change the configuration register value to 0x2142. The command is 'confreg 0x2142'. On some old routers, it is 'o/r 0x2142'* . This will turn on the 6th bit from right in the configuration-register, which makes the router to ignore the start-up configuration file in the NVRAM at start-up.

5. Now reload the router using the 'reset' command. On some old routers, the command is 'initialize' or just an 'i'*. It will load without the start-up configuration file which includes the password that is configured.

6. Since, no configuration has been copied to the RAM. The router will offer the setup mode to configure the router. Say 'No' to the setup mode.

7. Get to the router's enable mode. Since, the router has no configuration to refer to, it would not even prompt for a password.

8. (Crucial step. Make sure you dont make a mistake here! )Copy the startup-configuration to the running-configuration; use either 'copy start run' or 'configure memory'. You will have the entire configuration merged with the default configuration on the RAM including the passwords. Alternatively, you could use the command 'configure replace'.

9. If you have not encrypted the passwords, do a 'show run' and note down the passwords and proceed to step 12. Else move to step 10.

10. Change the passwords.

For console:

line con 0

password <password>

login

For privilege mode:

enable password <password> or enable secret password <password>

Use 'service password-encryption' for password encryption, if you like.

(If there is a password and a secret password, the secret password has eminence.)