Cisco IOS: password recovery notes

I’m pretty sure any CCNA worth his salt has this procedure down pat, but here’s a summary with things to remember if you’re too lazy to plow through Cisco.

1. Reboot the router, have your console terminal all connected and ready.

2. Send break signal to the router before the POST – on Teraterm this means Alt-B or click on Control then Send break

3. Alter the configuration register value to ignore NVRAM contents.

confreg 0x2142

4. Reboot the router again, so that you can boot into the router without a need for password.

5. Don’t get this command wrong after you enter privilege exec:

copy start run

Doing the reverse means a dump of an empty config onto your router. We are trying to edit the startup configuration, not overwrite the startup with the running (which is empty!).

6. Change the console and secret, change the configuration register back to default value.

config terminal

line con 0

password NEWPASSWORD

exit

enable secret NEWSECRET

configuration-register 0x2102

end

Don’t forget to write your new passwords down.

7. Save the configuration.

copy run start

8. Reboot the router, and enjoy.

Database: MySQL – Resetting the root password

(Yes, it just so happened that I had the opportunity to reset passwords for different stuff in the same week.)

Resetting the password is pretty easy for MySQL, so long as you have root access to the server. (I’m assuming Linux here.)

#1 Stop the service
We have to stop the running process before we do anything else, does that make sense?

/etc/init.d/mysql stop

This effectively stops the mysqld (daemon) from running.

#2 Start the service in safe mode
This allows us to start the service and login as root without a password.

mysqld_safe --skip-grant-tables &

#3 Login as root
Like what was previously mentioned, you don’t need a password!

mysql -u root

#4 Reset the root password with an UPDATE statement
Select the mysql database:

use mysql;

Update the password with an SQL UPDATE statement:

UPDATE user SET password=PASSWORD("newpassword") where User='root';

*Note: newpassword = the new password that you want to set. This command encrypts the plaintext password so that it cannot be read directly from the shadow file.

Reload the grant tables by flushing privileges:

flush privileges;

Exit the database:

quit

#5 Stop the service again, and restart it
We stop it:

/etc/init.d/mysql stop

And start it again:

/etc/init.d/mysql start

And we are all done! Remember to test if your new password works by logging in as root.

Linux – Debian: One way to reset the root password

So you have either fcuked things up and forgotten what that bloody complex root password (complete with symbols, numbers, uppercase and lowercase letters!) was like. Or perhaps you decided it was high time you cracked your roommate’s Linux box because he pissed you off the other night.

This is pretty straightforward actually, once you get the hang of things.

#1 Reboot the box
Unbelieveable as it sounds, you cannot change anything until you reboot the damn thing.

#2 Edit the startup configuration when you get to the GRUB loader
Select your desired operating system to load, and press e to edit the boot configuration.

Append this to the end of the statement:

init=/bin/bash

This makes the box boot into single-user mode, which conveniently gives you root access.

Press b to continue booting, and you should arrive in bash as root.

#3 Make your filesystem writable
Use this to do so:

mount / -o remount, rw

Skipping out on this will give you problems when attempting to change the password in the next step.

#4 Change the root password
Use this command to change the root password:

passwd

(That was easy!)

Enter your desired password after that. Twice.

#5 Reboot the box (again)
We’re rebooting now just to make sure our new password works.

And we’re all done; that was quick wasn’t it?

A detailed guide for other Linux distributions and bootloaders can be found at CLUG Wiki.