Lost Root and other user passwords

This isn't a huge deal, because there's very little on the server (literally a file or two) that we actually need off of it. But we disabled root logins as a security measure and can't remember any of our other user passwords.

I'm assuming that there's nothing we can do at this point to get into the server? I'm sitting next to the box...

Update

Oops... actually, I need to export an SVN off of this server. So yeah, there's stuff I need.

Update

I should point out, we're on Debian Lenny


Booting in single user mode won't work for Debian and Ubuntu because you still have to enter the root password for maintenance mode.

Reboot your computer to get to the grub boot screen, press e to edit one of your Grub boot configurations and edit the line starting with kernel. Append init=/bin/sh and boot the modified configuration by pressing b. When you arrived in your shell (without logging in this time) remount your file-system so it's in read/write mode: mount -o remount,rw /. Now you can start changing passwords with passwd now :)...


I will assume you are using Grub for you boot loader:

  1. Boot your system
  2. Select your kernel
  3. Press e
  4. Select the line that begins with kernel
  5. Append the letter S to the end of the line
  6. Press Enter then b

Boot into your single user mode.You should be greeted with the root prompt #. From here:

  1. type the command passwd and reset the root password
  2. Reboot. And login as root like normal

It would be really helpful if you could post a few details about your system. Which distro? Which bootloader?

Good luck!

Well ... Your other option is:

  1. Boot off of a rescue LiveCD
  2. Mount the root partition
  3. edit /etc/shadow (Delete everything between the first two colons in the root entry [see below])
  4. Then reboot and login to root without a password.
  5. Run the command passwd and reset the root password.

From this:

root:19udHWuh!:12581:0:99999:7:::

To this:

root::12581:0:99999:7:::

More info can be found at the Arch Linux wiki.


Boot into runlevel 1. Pass 1 as an extra argument on the kernel line from the bootloader.


If you have physical access to the server, you can always boot from a rescue disc, or even a liveCD and mount the old filesystem to copy the important stuff off.