Resetting OpenSolaris passwords
Between the new file system, ZFS, and some restrictions on the use of blank passwords, resetting a forgotten root password can be a bit of a pain unless you know exactly the right incantations. Having just found myself in the same boat, here they are…
First, boot from the OpenSolaris live CD and get yourself a root shell. The root password for the CD is ‘opensolaris’; the desktop is automatically logged in as user ‘jack’, so you can just su - from a terminal window.
Next, a zpool import -f rpool will pull in the disks – you need the -f (for force) and the name of the pool, since the file system will have been mounted by a different instance of Solaris previously. At this point, a zpool scrub might be a good idea too, unless you’re really in a hurry: it’s always good to know your data’s in pristine condition!
Next, you’ll need to mount the root file system. Normally, ZFS will expect it to mount on / – impossible in this case, of course, since your live CD is there! So, zfs list will tell you your file system names; one (or more, if you’ve previously used ZFS snapshots to update your system safely) of them will have a mountpoint of /, which will need to be changed – something like zfs set mountpoint=/export/tmp rpool/ROOT/opensolaris, followed by zfs mount rpool/ROOT/opensolaris.
That’s the difficult bit done: you now have write access to the shadow file, where the encrypted passwords live, in /export/tmp/etc/shadow. Delete the line noise after ‘root’ so the line begins ‘root::’ and root no longer has a password set. The file is marked read-only, but since you’ve logged in as root you can override this: ‘:x!’ does this in vi, my usual editor of choice for tasks like this.
Umount the filesystem again with zfs unmount rpool/ROOT/opensolaris, restore the mountpoint with zfs set mountpoint=/ rpool/ROOT/opensolaris, release the pool with zpool export and reboot.
One last hurdle: the GDM graphical login won’t allow anyone to log in with a blank password. If you know the password of another user who could then su to root, you can just log in as that user and you’re done; if not, read on!
To get around the GDM restriction, you’ll need a single-user console login prompt instead. This used to be easy – add -s to the boot command – but it’s a little more complex under Grub with OpenSolaris and the graphical boot system: it’s -m milestone=single-user to boot single-user now, but this won’t work with the graphical boot screen: you’ll just get some gibberish at the top of the screen as OpenSolaris writes the text console to a display in graphical mode. Just delete the splashimage, foreground and background entries, as well as the ,console=graphics option and you’ll be booting in plain old text mode. This time, you can log in as root with no password, then run passwd to set a new password for root and any other user you need, reboot and you’re all set.
Finally, make sure you remember the new password you’ve picked – it saves a lot of typing and waiting!
blog comments powered by Disqus