How do I logon as root if the password doesn't work anymore?

How do I logon as root if the password doesn't work anymore?

Regaining control of a Solaris x86 system where the root password has
been lost can be accomplished by the following steps. Note that
any savvy user can do this with the proper CD-ROM and diskette.
Therefore, of course, physical security of a system is important for
machines containing sensitive data.

1. Insert installation boot diskette and installation CD-ROM for
Solaris x86.

2. Boot system from the installation floppy and select the CD-ROM as
the boot device.

3. Type "b -s" (instead of typing 1 or 2 from the menu) and it'll
drop you straight to a root shell, #, (and you'll be in
single-user mode).

4. At the root prompt, #, key in the following commands, which will
create a directory called hdrive under the /tmp directory and then
mount the root hard drive partition under this temporary directory.



mkdir /tmp/hdrive
mount /dev/dsk/c0t0d0s0 /tmp/hdrive #SCSI; for ATAPI, omit "t0"

5. To use the vi editor, the TERM variable must be defined. Key in
the following commands.



TERM=at386
export TERM

6. Start vi (or some other editor) and load /tmp/hdrive/etc/shadow file:



vi /tmp/hdrive/etc/shadow

7. Change the first line of the shadow file that has the root entry to:



root::6445::::::

8. Write and quit the vi editor with the "!" override command:



:wq!

9. Halt the system, remove the floppy installation diskette, and
reboot the system:



halt

10. When system has rebooted from the hard drive, you can now log in
from the Console Login: as root with no password. Just hit enter
for the password.

11. After logging in as root, use the passwd command to change the
root password and secure the system.


[Thanks to Lynn R. Francis, Texas State Technical College]




Home
FAQ