Saturday, September 4, 2010

How to reset forgotten root password in SuSE Enterprise Server

We do sometimes forget our passwords and what more when we don’t login to that particular account regularly.  As good system administrators who automate most of the administrative tasks, we sometimes do not login to the root account often.  This is especially so for a highly reliable and robust SLES based system.

The following technique would also work for OpenSuSE, and also most other distributions.

Step 1:  Boot your server using the installation DVD.  If the server is already powered on, you will need to do a hard power-on as you can’t shutdown (since you don’t have the root password).













Step 2: Select “Resue System” and login as root.  No password is required here.













Step 3 : You have now booted into the live DVD, that is, you have booted from the DVD and the file system mounted is that of the DVD.  You will need to access your Hard Disk Drive which is not mounted by default. (In my scenario, my SuSE 11 partition is on an extended partition and is on device /dev/sda7.  Yours maybe different and if your system is a pure SuSE 11 (which should be the case), it is likely to be /dev/sda1, if using SATA or SCSI.  If using IDE, you can try /dev/hda1. To access (mount) the SuSE 11 partition on directory /mnt;

Use the below command

 #mount /dev/sda7 /mnt

Step 4: Edit /mnt/etc/shadow which is where the encrypted passwords are stored. Note that you are not suppose to edit /etc/shadow which is one used for the Live DVD.  Furthermore, you won’t be able to save the /etc/shadow as it is a read-only filesystem.

Step 5:  Search for the entry starting with “root:”.

Step 6: Remove 2nd field (the fields are separated by the ‘:’, resulting in something that resembles

root::14329::::::

Step 7: Save and exit your editor. Remove your DVD.

Step 8: Boot into single user mode by keying in “single” at the GRUB boot menu.  You will not be able to access or change root password if you boot into graphical mode.












Step 9: After booting, you will be greeted on the command line with “Press enter for login:”, do as it says and you are in.

Step 10 : Change root password by “passwd”.  Reboot.the system, now you will be able to login with your new password.

    

2 comments:

  1. i follow the steps but it asks password

    ReplyDelete
  2. can you tell me which step it asked password?

    ReplyDelete