Tuesday, 30 October 2012

Solaris - Resetting the Root password

Someone decided to change the root password and not test it while having the original logged in terminal window open. So we no longer had a working root password, so what to do!!

Well, found a number of useful links which covered SPARC and x86 (which seemed to look the same to me) but nothing about ZFS until I found the Oracle guide which was almost what I wanted.......

What you need to do is remove the root password entry in the shadow file and below is how I did that:


1. First of all you need to get to the <ok> prompt and boot into single user mode - in my case a Jumpstart server is used and not a DVD.

<ok> boot net -s

2. Once booted become root - which is a simple su <enter> (Running a ZFS list at this point produces no response).

3. Import the root pool and specify an alternative mount point.

# zpool import -R /a rpool

4. At this point you can run a ZFS list (# zfs list) to see what is available (I was interested as we also use Live Upgrade here so there were a number of BEs - I did have a couple of lines stating some parts failed to mount, but the ZFS list showed that a number BEs were available.

5. Mount a BE (in this case u10test).

# zfs mount rpool/ROOT/u10test

 6. Change to the /etc directory.

 # cd /a/etc

7. Now you can edit the shadow file (well, not quite as you'll get an error stating that the system doesn't know what input device you are using.....).

# TERM=vt100
# export TERM

8. Now you can edit the shadow file.

# vi shadow

9. Okay! What do I remove?

 root:BZQ8dnry$$MOOj3d71FeSNOngAAqIwY/:15643::::::

10. Remove the entries between root: and :15643 like so...

root::15643::::::

11. Save the file.

:wq!

12. Restart the server

# init 6

13. Log into the server (we log in with a normal account then su)

!!You will not be prompted for a password!!

14. Change your root password.

# passwd root

No comments:

Post a Comment