Suse & OpenSuse : Tips, Tricks, Tutorials, How Tos and Troubleshooting

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.

Our earlier posting was for OpenSuSE, but for SuSE, the security is even tighter.  The following technique would also work for OpenSuSE, and also most other distributions.

(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).

DSC00330

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

DSC00331

(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;

#mount /dev/sda7 /mnt

(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.

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

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

root::14329::::::

(7) Save and exit your editor. Remove your DVD.

(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.

DSC00333

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

(10) Change root password by “passwd”.  There you go … and reboot.

Any comments or ideas for further improvement are most welcome.

RSS feed | Trackback URI

2 Comments »

Comment by lopez
2009-06-12 03:33:15

It works!

Thanks.

 
Comment by David
2009-07-16 13:29:24

Great article! Worked the first time and saved me hours of reloading.

Thanks!

 
Name (required)
E-mail (required - never shown publicly)
URI
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> in your comment.