Difference between revisions of "Lost Password"

From FreekiWiki
Jump to navigation Jump to search
(merged from "How to Root a Box")
Line 1: Line 1:
The following applies to most linux boxen.  It can be used on an Ubuntu box (which has no root password) to recover the user password.
+
The following applies to most linux boxen.  It can be used to recover a lost [[root]] password and is also called "rooting" the box.  It can be used on an Ubuntu box (which has no root password) to recover the user password.
  
 
Generally it is easiest if the adopter brings the box in, but alternatively you can walk the adopter through the following:
 
Generally it is easiest if the adopter brings the box in, but alternatively you can walk the adopter through the following:
Line 7: Line 7:
  
 
#start the computer booting up
 
#start the computer booting up
#at the GRUB screen enter "e"
+
#:After 10 or 20 seconds you will see After a few (or 10 or 20) seconds you will see a screen that says... '''Grub Loading...3..2..1'''.  (If the box was installed from a CD, rather than our system, you may need to press ESC here in order to see the GRUB menu in the step below)
 +
#Next you will see several lines that start with '''Ubuntu, kernel 2.6...''', this is the GRUB menu.  hit the down arrow key very quickly when you see this or it will disappear in 2 seconds.
 +
#at the top line of the GRUB menu enter "e"
 
#edit the line starting with "kernel" by selecting that line and entering "e"
 
#edit the line starting with "kernel" by selecting that line and entering "e"
 
##delete "quiet" and "splash" at the end of the line (if there)
 
##delete "quiet" and "splash" at the end of the line (if there)
Line 14: Line 16:
 
##enter to make the changes
 
##enter to make the changes
 
#enter "b" to continue the boot process
 
#enter "b" to continue the boot process
#the boot will go to a root prompt.
+
#the boot will go to a root prompt. which will look something like '''"root@(none)"'''
The prompt will be something like "root@(none)"
 
  
  
the passwd command can be used to change the root password on a debian box
+
The '''passwd''' command can be used to change the root password most linux boxes
  
If this is an Ubuntu box, you will need to change the password of the first user.   
+
If this is an Ubuntu box, you will need to change the password of the first user insteadType passwd and then hit Tab twice to get a list of users on the system. or use "ls /home" to find out the names of the users.
Use "ls /home" to find out the name of the user
 
  
 
The password for a user account can be changed at this point.
 
The password for a user account can be changed at this point.
  
 
  passwd <username>
 
  passwd <username>
 +
 +
*It will say enter new UNIX password enter a new password. Hit enter.
 +
*Retype it to confirm. Hit enter.
 +
*type "sync" and Hit enter. (this ensures that the files are written to disk)
 +
*Remember Both the username and password and restart the computer.
 +
*login with the old name and new password. If it works, Yay! if not, Repeat!
  
  
Line 31: Line 37:
  
 
==live CD method==
 
==live CD method==
If the box does not use grub to boot, one can boot the box using a knoppix cd, a rescue floppy, or a Toms Root Boot disk, then login as root and proceed as above.
+
If the box does not use grub to boot, one can boot the box using a live cd, a rescue floppy, or a Toms Root Boot disk, then login as root and proceed as above.
  
 
#"mount /dev/hda3 /mnt"  
 
#"mount /dev/hda3 /mnt"  

Revision as of 18:11, 22 January 2008

The following applies to most linux boxen. It can be used to recover a lost root password and is also called "rooting" the box. It can be used on an Ubuntu box (which has no root password) to recover the user password.

Generally it is easiest if the adopter brings the box in, but alternatively you can walk the adopter through the following:

GRUB method

Edit the grub boot commands.

  1. start the computer booting up
    After 10 or 20 seconds you will see After a few (or 10 or 20) seconds you will see a screen that says... Grub Loading...3..2..1. (If the box was installed from a CD, rather than our system, you may need to press ESC here in order to see the GRUB menu in the step below)
  2. Next you will see several lines that start with Ubuntu, kernel 2.6..., this is the GRUB menu. hit the down arrow key very quickly when you see this or it will disappear in 2 seconds.
  3. at the top line of the GRUB menu enter "e"
  4. edit the line starting with "kernel" by selecting that line and entering "e"
    1. delete "quiet" and "splash" at the end of the line (if there)
    2. change "ro" to "rw"
    3. add "init=/bin/bash" to the end
    4. enter to make the changes
  5. enter "b" to continue the boot process
  6. the boot will go to a root prompt. which will look something like "root@(none)"


The passwd command can be used to change the root password most linux boxes

If this is an Ubuntu box, you will need to change the password of the first user instead. Type passwd and then hit Tab twice to get a list of users on the system. or use "ls /home" to find out the names of the users.

The password for a user account can be changed at this point.

passwd <username>
  • It will say enter new UNIX password enter a new password. Hit enter.
  • Retype it to confirm. Hit enter.
  • type "sync" and Hit enter. (this ensures that the files are written to disk)
  • Remember Both the username and password and restart the computer.
  • login with the old name and new password. If it works, Yay! if not, Repeat!


See how insecure the box is if you have physical access to it?

live CD method

If the box does not use grub to boot, one can boot the box using a live cd, a rescue floppy, or a Toms Root Boot disk, then login as root and proceed as above.

  1. "mount /dev/hda3 /mnt"
  2. "chroot /mnt"
  3. "passwd"
  4. change password
  5. "sync"
  6. reboot

The procedure can be used for distributions other than the freekbox2 or 3, but you first need to determine the name of the root partition for the mount command.